forked from zbw/sparql-queries
-
Notifications
You must be signed in to change notification settings - Fork 0
/
geographic_entities.rq
53 lines (52 loc) · 1.49 KB
/
geographic_entities.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
52
# Selection of geographich entities
#
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 ?item ?itemLabel
WHERE {
{
SELECT ?item ?itemLabel WHERE {
# instances of ...
{
# state of Germany
?item wdt:P31 wd:Q1221156
} union {
# country
?item wdt:P31 wd:Q6256
} union {
# geographic region
?item wdt:P31 wd:Q82794
} union {
# political union
?item wdt:P31 wd:Q1140229
## # manually selected items
## # (possibly as an alternative to the two clauses above)
## } union {
## values (?itemID) {
## ('Q919721') # Eastern Germany
## ('Q458') # EU
## ('Q181574') # NAFTA
## }
## bind(uri(concat('http://www.wikidata.org/entity/', ?itemID)) as ?item)
}
#
SERVICE wikibase:label {
# returns German (preferred) or English label, or
# entity name if neither exists
bd:serviceParam wikibase:language "de,en" .
}
}
}
# autosuggest string to inject
filter(regex(str(?itemLabel), "^ost", "i"))
# filter out entity names
filter(!strends(str(?item), ?itemLabel))
}
order by str(?itemLabel)