query-c4d1f72b192d8d925cd1dd4f4c696876
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 wd: <http://www.wikidata.org/entity/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT (IRI(concat("https://commons.wikimedia.org/wiki/", ?creatorTemplate)) as ?creatorLink) ?creatorName ?categoryName ?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 templates 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" .
?creatorTemplate wikibase:apiOutput mwapi:title .
}
SERVICE wikibase:mwapi { # get home category
bd:serviceParam wikibase:api "Categories" .
bd:serviceParam wikibase:endpoint "commons.wikimedia.org" .
bd:serviceParam mwapi:titles ?creatorTemplate .
bd:serviceParam mwapi:clshow "!hidden" .
?category wikibase:apiOutput mwapi:category .
}
BIND(substr(?creatorTemplate,9) as ?creatorName ) .
BIND(substr(?category,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) ) .
FILTER ( ?commonsCatItem!=wd:Q24731821 ) .
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v3("?category")
v5("?categoryName"):::projected
v1("?commonsCatItem"):::projected
v6("?creatorLink")
v4("?creatorName"):::projected
v2("?creatorTemplate"):::projected
c19(["descending"]):::literal
c9(["Category:Creator templates without Wikidata link"]):::literal
c3(["bd:serviceParam"]):::iri
c26(["mwapi:category"]):::iri
c25(["!hidden"]):::literal
c7(["commons.wikimedia.org"]):::literal
c17(["timestamp"]):::literal
c15(["max"]):::literal
c22(["Categories"]):::literal
c11(["categorymembers"]):::literal
c30(["#91;AUTO_LANGUAGE#93;,en"]):::literal
c13(["page"]):::literal
c21(["mwapi:title"]):::iri
c5(["Generator"]):::literal
f0[["?commonsCatItem != 'wd:Q24731821'"]]
f0 --> v1
f1[["bound(?commonsCatItem)"]]
f1 --> v1
subgraph s1["http://wikiba.se/ontology#mwapi"]
style s1 stroke-width:4px;
c3 --"mwapi:api"--> c5
c3 --"mwapi:endpoint"--> c7
c3 --"mwapi:gcmtitle"--> c9
c3 --"mwapi:generator"--> c11
c3 --"mwapi:gcmtype"--> c13
c3 --"mwapi:gcmlimit"--> c15
c3 --"mwapi:gcmsort"--> c17
c3 --"mwapi:gcmdir"--> c19
v2 --"mwapi:apiOutput"--> c21
end
subgraph s1["http://wikiba.se/ontology#mwapi"]
style s1 stroke-width:4px;
c3 --"mwapi:api"--> c22
c3 --"mwapi:endpoint"--> c7
c3 --"mwapi:titles"--> v2
c3 --"mwapi:clshow"--> c25
v3 --"mwapi:apiOutput"--> c26
end
bind2[/"substring(?creatorTemplate,'9^^xsd:integer')"/]
v2 --o bind2
bind2 --as--o v4
bind3[/"substring(?category,'10^^xsd:integer')"/]
v3 --o bind3
bind3 --as--o v5
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v1 -."wdt:P373".-> v5
subgraph s2["http://wikiba.se/ontology#label"]
style s2 stroke-width:4px;
c3 --"mwapi:language"--> c30
end
end
bind4[/"concat('https://commons.wikimedia.org/wiki/',?creatorTemplate)"/]
v2 --o bind4
bind4 --as--o v6