query-99cdda1eee9db24a6de8e2d28774e507
11:52, 12 July 2021 (UTC)) talk (MarioGomSome of them might be correct, but in the absence of references, I assume most are data entry errors. 12:38, 12 July 2021 (UTC)) talk (Tagishsimon --https://w.wiki/3d9sYes. Some patterns: 12:43, 12 July 2021 (UTC) Jura for this. --- Property talk:P27 on }}Complex constraint{{It would be good to have a 13:34, 12 July 2021 (UTC) JuraI think checking if the P27 has a reference is a good idea. --- 13:08, 12 July 2021 (UTC)) talk (TagishsimonGood luck with some SPARQL which doesn't produce hundreds of thousands of false positives. Messy business, countries & citizenships. --
Use at
- https://query.wikidata.org/sparql
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX prov: <http://www.w3.org/ns/prov#>
PREFIX p: <http://www.wikidata.org/prop/>
SELECT DISTINCT ?item
{
?item wdt:P27 wd:Q784 .
?item wdt:P19/wdt:P17? wd:Q786 .
FILTER NOT EXISTS { ?item wdt:P27 wd:Q786 }
?item wdt:P31 wd:Q5.
?item p:P27 ?claim .
?claim ps:P27 wd:Q784 .
OPTIONAL { ?claim prov:wasDerivedFrom ?source . ?source ?p ?v . FILTER NOT EXISTS { ?v wdt:P31 wd:Q10876391 } }
FILTER(!bound(?source))
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v4("?claim")
v2("?item"):::projected
v5("?p")
v1("?source")
v3("?v")
a1((" "))
c2(["wd:Q786"]):::iri
c5(["wd:Q784"]):::iri
c8(["wd:Q5"]):::iri
c4(["wd:Q10876391"]):::iri
f0[["not bound(?source)"]]
f0 --> v1
f1[["not "]]
subgraph f1e0["Exists Clause"]
e0v1 --"p:direct/P27"--> e0c2
e0v1("?item"):::projected
e0c2(["wd:Q786"]):::iri
end
f1--EXISTS--> f1e0
f1 --> v2
f1 --> c1
f1 --> c2
v2 --"p:direct/P27"--> c2
v2 --"p:direct/P27"--> c5
v2 --"p:direct/P19"--> a1
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
a1 --"p:direct/P17"--> c2
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
end
union0r <== or ==> union0l
end
v2 --"p:direct/P31"--> c8
v2 --"p:P27"--> v4
v4 --"p:statement/P27"--> c5
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v4 -."prov:wasDerivedFrom".-> v1
v1 -->v5--> v3
end