query-c92723337ca5afe8fd30a25df011cf3e
However, a more detailed selection to get all the right organizations can be quite detailed (and still get a few false positives).
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT DISTINCT ?item ?itemLabel ?typeLabel ?classLabel WHERE {
VALUES ?country { wd:Q34 } #Change country here
?item wdt:P31/wdt:P279* wd:Q2659904 ;
wdt:P17 ?country ;
wdt:P31 ?type .
MINUS { ?item p:P17 ?a ; p:P17 ?b . FILTER(STR(?a) < STR(?b)) } # Removes items run by several contries
OPTIONAL { ?item wdt:P137 ?operator }
BIND(COALESCE(?operator,?country) AS ?op )
FILTER(?op = ?country) #Deselects (mostly) embassies of other countries in the country
MINUS {?item wdt:P361 ?partof. ?partof wdt:P576 []}
MINUS {?item wdt:P279 ?class. ?class wdt:P361 wd:Q15238777 }
MINUS {?item wdt:P279 ?class. ?class wdt:P576 [] }
MINUS {?item wdt:P576 []}
MINUS {?item wdt:P582 []}
MINUS {?item wdt:P2669 []}
MINUS {?type wdt:P576 []}
SERVICE wikibase:label { bd:serviceParam wikibase:language "sv,en". }
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v5("?a")
v6("?b")
v9("?class")
v3("?country")
v3("?item"):::projected
v8("?op")
v7("?operator")
v8("?partof")
v4("?type")
a2((" "))
a3((" "))
a4((" "))
a5((" "))
a1((" "))
a6((" "))
a7((" "))
c3(["wd:Q2659904"]):::iri
c9(["wd:Q15238777"]):::iri
c13(["bd:serviceParam"]):::iri
c15(["sv,en"]):::literal
f0[["?op = ?country"]]
f0 --> v8
f0 --> v3
bind1[/VALUES ?country/]
bind1-->v3
bind10(["wd:Q34"])
bind10 --> bind1
v3 --"p:direct/P31"--> a1
a1 --"p:direct/P279"--> c3
v3 --"p:direct/P17"--> v3
v3 --"p:direct/P31"--> v4
subgraph minus2["MINUS"]
style minus2 stroke-width:6px,fill:pink,stroke:red;
f3[["str(?a) < str(?b)"]]
f3 --> v5
f3 --> v6
v3 --"p:P17"--> v5
v3 --"p:P17"--> v6
end
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v3 -."p:direct/P137".-> v7
end
bind4[/"?operator?country"/]
v7 --o bind4
v3 --o bind4
bind4 --as--o v8
subgraph minus5["MINUS"]
style minus5 stroke-width:6px,fill:pink,stroke:red;
v3 --"p:direct/P361"--> v8
v8 --"p:direct/P576"--> a2
end
subgraph minus6["MINUS"]
style minus6 stroke-width:6px,fill:pink,stroke:red;
v3 --"p:direct/P279"--> v9
v9 --"p:direct/P361"--> c9
end
subgraph minus7["MINUS"]
style minus7 stroke-width:6px,fill:pink,stroke:red;
v3 --"p:direct/P279"--> v9
v9 --"p:direct/P576"--> a3
end
subgraph minus8["MINUS"]
style minus8 stroke-width:6px,fill:pink,stroke:red;
v3 --"p:direct/P576"--> a4
end
subgraph minus9["MINUS"]
style minus9 stroke-width:6px,fill:pink,stroke:red;
v3 --"p:direct/P582"--> a5
end
subgraph minus10["MINUS"]
style minus10 stroke-width:6px,fill:pink,stroke:red;
v3 --"p:direct/P2669"--> a6
end
subgraph minus11["MINUS"]
style minus11 stroke-width:6px,fill:pink,stroke:red;
v4 --"p:direct/P576"--> a7
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c13 --"wikibase:language"--> c15
end