forked from zbw/sparql-queries
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconstruct_wd_category_mappings.rq
45 lines (45 loc) · 1.46 KB
/
construct_wd_category_mappings.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
# Get mappings for all categories (geo/subject/ware)
#
PREFIX bd: <http://www.bigdata.com/rdf#>
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/>
#
construct {
?item skos:exactMatch ?pm20Category .
}
##select ?item ?pm20Category
where {
{
# for wares, a few special pm20 category items plus "normal" items are matched
service <https://query.wikidata.org/sparql> {
?item wdt:P10890 ?wareId .
}
bind (uri(concat('https://pm20.zbw.eu/category/ware/i/', ?wareId)) as ?pm20Category)
} union {
graph <http://zbw.eu/beta/geo/ng> {
service <https://query.wikidata.org/sparql> {
# for countries, only "normal" items (a few non-exact matches)
## TODO only exact matches?
?item wdt:P8483 ?geoCode .
}
# look up code (=> notation)
bind(replace(?geoCode, '_', ' ') as ?notation)
?geo skos:notation ?notation .
bind(?geo as ?pm20Category)
}
} union {
graph <http://zbw.eu/beta/subject/ng> {
service <https://query.wikidata.org/sparql> {
# for subjects, only special pm20 category items are matched
?item wdt:P8484 ?subjectCode .
}
# look up code (=> notation)
bind(replace(?subjectCode, '_', ' ') as ?notation)
?subject skos:notation ?notation .
bind(?subject as ?pm20Category)
}
}
}
order by ?pm20Category