query-9f29598a04b1cf8e5b696714e2efe4c6
PropertiesCommons category (P373)
Use at
- https://query.wikidata.org/sparql
PREFIX mwapi: <http://wikiba.se/ontology#>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT (IRI(concat("https://commons.wikimedia.org/wiki/", ?homeCategory)) as ?homeCategoryLink) ?homeCategory ?commonsCatItem ?commonsCatItemLabel {
SERVICE wikibase:mwapi { # list of all creator templates without Wikidata link
bd:serviceParam wikibase:api "Generator" .
bd:serviceParam wikibase:endpoint "commons.wikimedia.org" .
bd:serviceParam mwapi:gcmtitle "Category:Creator template home categories without Wikidata link" .
bd:serviceParam mwapi:generator "categorymembers" .
bd:serviceParam mwapi:gcmtype "page" .
bd:serviceParam mwapi:gcmlimit "max" .
bd:serviceParam mwapi:gcmsort "timestamp" .
bd:serviceParam mwapi:gcmdir "descending" .
?homeCategory wikibase:apiOutput mwapi:title .
}
BIND(substr(?homeCategory,10) as ?categoryName) .
OPTIONAL {
?commonsCatItem wdt:P373 ?categoryName . # category is linked from Wikidata
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
}
FILTER ( BOUND(?commonsCatItem) ) .
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v3("?categoryName")
v1("?commonsCatItem"):::projected
v2("?homeCategory"):::projected
v4("?homeCategoryLink")
c14(["max"]):::literal
c18(["descending"]):::literal
c10(["categorymembers"]):::literal
c2(["bd:serviceParam"]):::iri
c24(["#91;AUTO_LANGUAGE#93;,en"]):::literal
c8(["Category:Creator template home categories without Wikidata link"]):::literal
c12(["page"]):::literal
c20(["mwapi:title"]):::iri
c6(["commons.wikimedia.org"]):::literal
c4(["Generator"]):::literal
c16(["timestamp"]):::literal
f0[["bound(?commonsCatItem)"]]
f0 --> v1
subgraph s1["http://wikiba.se/ontology#mwapi"]
style s1 stroke-width:4px;
c2 --"mwapi:api"--> c4
c2 --"mwapi:endpoint"--> c6
c2 --"mwapi:gcmtitle"--> c8
c2 --"mwapi:generator"--> c10
c2 --"mwapi:gcmtype"--> c12
c2 --"mwapi:gcmlimit"--> c14
c2 --"mwapi:gcmsort"--> c16
c2 --"mwapi:gcmdir"--> c18
v2 --"mwapi:apiOutput"--> c20
end
bind1[/"substring(?homeCategory,'10^^xsd:integer')"/]
v2 --o bind1
bind1 --as--o v3
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v1 -."wdt:P373".-> v3
subgraph s2["http://wikiba.se/ontology#label"]
style s2 stroke-width:4px;
c2 --"mwapi:language"--> c24
end
end
bind2[/"concat('https://commons.wikimedia.org/wiki/',?homeCategory)"/]
v2 --o bind2
bind2 --as--o v4