Skip to content

Instantly share code, notes, and snippets.

@nyurik
Created December 8, 2017 07:38
Show Gist options
  • Save nyurik/f20796f23a8b73479a739ec923f411d7 to your computer and use it in GitHub Desktop.
Save nyurik/f20796f23a8b73479a739ec923f411d7 to your computer and use it in GitHub Desktop.
All european sub-regions with their languages
SELECT
?id
# remove possible duplicates
(SAMPLE(?iso_3166_2) as ?iso_3166_2)
(SAMPLE(?insee_fr) as ?insee_fr)
(SAMPLE(?flagImg) as ?flagImg)
# all of the official languages in the European Union
(SAMPLE(?label_bg) as ?label_bg)
(SAMPLE(?label_cs) as ?label_cs)
(SAMPLE(?label_da) as ?label_da)
(SAMPLE(?label_de) as ?label_de)
(SAMPLE(?label_el) as ?label_el)
(SAMPLE(?label_en) as ?label_en)
(SAMPLE(?label_es) as ?label_es)
(SAMPLE(?label_et) as ?label_et)
(SAMPLE(?label_fi) as ?label_fi)
(SAMPLE(?label_fr) as ?label_fr)
(SAMPLE(?label_ga) as ?label_ga)
(SAMPLE(?label_hr) as ?label_hr)
(SAMPLE(?label_hu) as ?label_hu)
(SAMPLE(?label_it) as ?label_it)
(SAMPLE(?label_lb) as ?label_lb)
(SAMPLE(?label_lt) as ?label_lt)
(SAMPLE(?label_lv) as ?label_lv)
(SAMPLE(?label_mt) as ?label_mt)
(SAMPLE(?label_nl) as ?label_nl)
(SAMPLE(?label_pl) as ?label_pl)
(SAMPLE(?label_pt) as ?label_pt)
(SAMPLE(?label_ro) as ?label_ro)
(SAMPLE(?label_sk) as ?label_sk)
(SAMPLE(?label_sl) as ?label_sl)
(SAMPLE(?label_sv) as ?label_sv)
(SAMPLE(?label_tr) as ?label_tr)
WHERE {
# P150 = "contains administrative territorial entity"
# Anything that is a P150 of anything that is a P150 of EU.
wd:Q458 wdt:P150 ?entity .
?entity p:P150 ?s .
?s ps:P150 ?id .
FILTER NOT EXISTS { ?s pq:P582 ?x } # has no P582 (end date) qualifier
OPTIONAL { ?id wdt:P300 ?iso_3166_2 }
OPTIONAL { ?id wdt:P2585 ?insee_fr }
OPTIONAL { ?id wdt:P41 ?flagImg }
OPTIONAL { ?id rdfs:label ?label_bg. FILTER(LANG(?label_bg) = "bg") }
OPTIONAL { ?id rdfs:label ?label_cs. FILTER(LANG(?label_cs) = "cs") }
OPTIONAL { ?id rdfs:label ?label_da. FILTER(LANG(?label_da) = "da") }
OPTIONAL { ?id rdfs:label ?label_de. FILTER(LANG(?label_de) = "de") }
OPTIONAL { ?id rdfs:label ?label_el. FILTER(LANG(?label_el) = "el") }
OPTIONAL { ?id rdfs:label ?label_en. FILTER(LANG(?label_en) = "en") }
OPTIONAL { ?id rdfs:label ?label_es. FILTER(LANG(?label_es) = "es") }
OPTIONAL { ?id rdfs:label ?label_et. FILTER(LANG(?label_et) = "et") }
OPTIONAL { ?id rdfs:label ?label_fi. FILTER(LANG(?label_fi) = "fi") }
OPTIONAL { ?id rdfs:label ?label_fr. FILTER(LANG(?label_fr) = "fr") }
OPTIONAL { ?id rdfs:label ?label_ga. FILTER(LANG(?label_ga) = "ga") }
OPTIONAL { ?id rdfs:label ?label_hr. FILTER(LANG(?label_hr) = "hr") }
OPTIONAL { ?id rdfs:label ?label_hu. FILTER(LANG(?label_hu) = "hu") }
OPTIONAL { ?id rdfs:label ?label_it. FILTER(LANG(?label_it) = "it") }
OPTIONAL { ?id rdfs:label ?label_lb. FILTER(LANG(?label_lb) = "lb") }
OPTIONAL { ?id rdfs:label ?label_lt. FILTER(LANG(?label_lt) = "lt") }
OPTIONAL { ?id rdfs:label ?label_lv. FILTER(LANG(?label_lv) = "lv") }
OPTIONAL { ?id rdfs:label ?label_mt. FILTER(LANG(?label_mt) = "mt") }
OPTIONAL { ?id rdfs:label ?label_nl. FILTER(LANG(?label_nl) = "nl") }
OPTIONAL { ?id rdfs:label ?label_pl. FILTER(LANG(?label_pl) = "pl") }
OPTIONAL { ?id rdfs:label ?label_pt. FILTER(LANG(?label_pt) = "pt") }
OPTIONAL { ?id rdfs:label ?label_ro. FILTER(LANG(?label_ro) = "ro") }
OPTIONAL { ?id rdfs:label ?label_sk. FILTER(LANG(?label_sk) = "sk") }
OPTIONAL { ?id rdfs:label ?label_sl. FILTER(LANG(?label_sl) = "sl") }
OPTIONAL { ?id rdfs:label ?label_sv. FILTER(LANG(?label_sv) = "sv") }
OPTIONAL { ?id rdfs:label ?label_tr. FILTER(LANG(?label_tr) = "tr") }
} GROUP BY ?id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment