query-7202e45e3817f6cc4cfc511575f96dcb
Looking for items where category saved in sitelink to Commons does not match P373I observed that often after category rename, new category is placed in a sitelink but P373 is not updated. So I am looking for such cases. I was trying:
Use at
- https://query.wikidata.org/sparql
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX schema: <http://schema.org/>
SELECT ?item ?commonsCategory ?commonsSitelink ?category
WHERE {
?item wdt:P373 ?commonsCategory .
?commonsSitelink schema:about ?item; schema:isPartOf <https://commons.wikimedia.org/>; schema:name ?sitelink_label .
FILTER(STRSTARTS(STR(?commonsSitelink), "https://commons.wikimedia.org/wiki/Category")) . # sitelink to a category
BIND(substr(?sitelink_label,10) as ?category) . # strip "Category:" part
FILTER( false = (?category = ?commonsCategory) )
#FILTER(false = STRENDS(STR(?commonsSitelink), ENCODE_FOR_URI(?commonsCategory)))
} LIMIT 10
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v6("?category"):::projected
v2("?commonsCategory"):::projected
v3("?commonsSitelink"):::projected
v4("?item"):::projected
v5("?sitelink_label")
c6([https://commons.wikimedia.org/]):::iri
f0[["'false^^xsd:boolean' = ?category = ?commonsCategory"]]
f0 --> v6
f0 --> v2
f1[["starts-with(str(?commonsSitelink),'https://commons.wikimedia.org/wiki/Category')"]]
f1 --> v3
v4 --"wdt:P373"--> v2
v3 --"schema:about"--> v4
v3 --"schema:isPartOf"--> c6
v3 --"schema:name"--> v5
bind2[/"substring(?sitelink_label,'10^^xsd:integer')"/]
v5 --o bind2
bind2 --as--o v6