query-31e2888a9556a7f3943e80545e8f1398
TODO
Use at
- https://query.wikidata.org/sparql
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX schema: <http://schema.org/>
SELECT (count(DISTINCT ?categoryItem ) as ?total) WHERE {
# ?article and ?category share the same P373 ("Commons Category")
?articleItem wdt:P373 ?commonsCategory .
?categoryItem wdt:P373 ?commonsCategory .
# P301 and P910 are set properly
?articleItem wdt:P910 ?categoryItem .
?categoryItem wdt:P301 ?articleItem .
# sitelink to Commons points to the same category as property P373
?commonsSitelink schema:about ?categoryItem .
FILTER(STRSTARTS(STR(?commonsSitelink), "https://commons.wikimedia.org/wiki/Category"))
FILTER(STRENDS(STR(?commonsSitelink), ?commonsCategory))
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v3("?articleItem")
v4("?categoryItem"):::projected
v2("?commonsCategory")
v1("?commonsSitelink")
v5("?total")
f0[["ends-with(str(?commonsSitelink),?commonsCategory)"]]
f0 --> v1
f0 --> v2
f1[["starts-with(str(?commonsSitelink),'https://commons.wikimedia.org/wiki/Category')"]]
f1 --> v1
v3 --"wdt:P373"--> v2
v4 --"wdt:P373"--> v2
v3 --"wdt:P910"--> v4
v4 --"wdt:P301"--> v3
v1 --"schema:about"--> v4
bind3[/"count(?categoryItem)"/]
v4 --o bind3
bind3 --as--o v5