forked from zbw/sparql-queries
-
Notifications
You must be signed in to change notification settings - Fork 0
/
geographic_entities_codelist.rq
52 lines (51 loc) · 1.54 KB
/
geographic_entities_codelist.rq
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# Geographic entities code list (for import into SowiDataNet repository)
#
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX v: <http://www.wikidata.org/prop/statement/>
PREFIX bd: <http://www.bigdata.com/rdf#>
#
SELECT distinct ?itemId (str(?label_de) as ?de) (str(?label_en) as ?en) ?isoCode ?link ("Wikidata Link" as ?linkLabel)
WHERE {
# select items by different criteria
{
# ISO 3166-1 alpha-2 code
?item wdt:P297 ?isoCode .
} union {
# ISO 3166-2 code
?item wdt:P300 ?iso2Code .
# restrict to states of Germany
?item wdt:P31 wd:Q1221156
} union {
# manually selected items
values (?itemID) {
('Q919721') # Eastern Germany
('Q458') # EU
('Q181574') # NAFTA
}
bind(uri(concat('http://www.wikidata.org/entity/', ?itemID)) as ?item)
}
# Wikdata item identifier
bind(strafter(str(?item), 'http://www.wikidata.org/entity/') as ?itemId)
# Labels
optional {
?item rdfs:label ?label_en
filter(lang(?label_en) = 'en')
}
optional {
?item rdfs:label ?label_de
filter(lang(?label_de) = 'de')
}
# Link to Sqid item page
bind(uri(concat("https://tools.wmflabs.org/sqid/#/view?id=", ?itemId)) as ?link)
#
## # optionally supplement with GND identifier
## optional {
## ?item wdt:P227 ?gndId
## }
}
order by str(?label_de)