query-e6bf00db215441ebbe59f481400bee3b

rq turtle/ttl

PropertiesCommons category (P373)instance of (P31)

Use at

PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX schema: <http://schema.org/>
SELECT (Count(?item) as ?count) WHERE {
    # ?article and ?category share the same P373 ("Commons Category")
    MINUS{ ?item  wdt:P373 ?commonsCategory . }
    MINUS{ ?item wdt:P31 wd:Q4167836 . }

    # sitelink to Commons points to the same category as property P373
    ?commonsSitelink schema:about ?item .
    FILTER(STRSTARTS(STR(?commonsSitelink), "https://commons.wikimedia.org/wiki/Category"))
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v3("?commonsCategory") v1("?commonsSitelink") v4("?count") v2("?item"):::projected c4(["wd:Q4167836"]):::iri f0[["starts-with(str(?commonsSitelink),'https://commons.wikimedia.org/wiki/Category')"]] f0 --> v1 subgraph minus1["MINUS"] style minus1 stroke-width:6px,fill:pink,stroke:red; v2 --"wdt:P373"--> v3 end subgraph minus2["MINUS"] style minus2 stroke-width:6px,fill:pink,stroke:red; v2 --"wdt:P31"--> c4 end v1 --"schema:about"--> v2 bind4[/"count(?item)"/] v2 --o bind4 bind4 --as--o v4