query-29521a56c81366c32bc4c0f072cb7f2f

rq turtle/ttl

Wikidata entries for British ambassadors and high commissioners

items are mostly internal linking infrastructure (is it a class of Ambassador to X, etc)

select distinct ?item ?itemLabel ?otherclass ?otherclassLabel ?startyear ?category ?categoryLabel ?list ?listLabel ?embassyLabel where { { ?item wdt:P31 wd:Q18115939 . } union { ?item wdt:P31 wd:Q56760832 } . # ambassador or high commissioner optional { ?item wdt:P31 ?otherclass . ?otherclass wdt:P279* wd:Q121998 . minus {?otherclass wdt:P17 wd:Q145 } . } optional { ?item wdt:P2354 ?list } . optional { ?item wdt:P910 ?category } . optional { ?item wdt:P571 ?start . bind(year(?start) as ?startyear) } . optional { ?item wdt:P2389 ?embassy . }

SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } }

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX bd: <http://www.bigdata.com/rdf#>
# Wikidata entries for British ambassadors and high commissioners
# items are mostly internal linking infrastructure (is it a class of Ambassador to X, etc)

select distinct ?item ?itemLabel ?otherclass ?otherclassLabel ?startyear ?category ?categoryLabel ?list ?listLabel ?embassyLabel where
{
  { ?item wdt:P31 wd:Q18115939 . } union { ?item wdt:P31 wd:Q56760832 } . # ambassador or high commissioner
  optional { ?item wdt:P31 ?otherclass . ?otherclass wdt:P279* wd:Q121998 . minus {?otherclass wdt:P17 wd:Q145 } . }
  optional { ?item wdt:P2354 ?list } .
  optional { ?item wdt:P910 ?category } .
  optional { ?item wdt:P571 ?start . bind(year(?start) as ?startyear) } .
  optional { ?item wdt:P2389 ?embassy . } 

  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v4("?category"):::projected v7("?embassy") v1("?item"):::projected v3("?list"):::projected v2("?otherclass"):::projected v5("?start") v6("?startyear"):::projected c2(["wd:Q18115939"]):::iri c3(["wd:Q56760832"]):::iri c13(["bd:serviceParam"]):::iri c5(["wd:Q121998"]):::iri c15(["#91;AUTO_LANGUAGE#93;,en"]):::literal c7(["wd:Q145"]):::iri subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; v1 --"wdt:P31"--> c3 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v1 --"wdt:P31"--> c2 end union0r <== or ==> union0l end subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v1 -."wdt:P31".-> v2 v2 --"wdt:P279"--> c5 subgraph minus0["MINUS"] style minus0 stroke-width:6px,fill:pink,stroke:red; v2 --"wdt:P17"--> c7 end end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v1 -."wdt:P2354".-> v3 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v1 -."wdt:P910".-> v4 end subgraph optional3["(optional)"] style optional3 fill:#bbf,stroke-dasharray: 5 5; v1 -."wdt:P571".-> v5 bind1[/"year-from-dateTime(?start)"/] v5 --o bind1 bind1 --as--o v6 end subgraph optional4["(optional)"] style optional4 fill:#bbf,stroke-dasharray: 5 5; v1 -."wdt:P2389".-> v7 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c13 --"wikibase:language"--> c15 end