forked from zbw/sparql-queries
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wd_occupation_economist.rq
40 lines (39 loc) · 1.32 KB
/
wd_occupation_economist.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
# Extract information about occupations from GND for Wikidata
#
PREFIX gndo: <https://d-nb.info/standards/elementset/gnd#>
PREFIX gnd: <https://d-nb.info/gnd/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
#
select distinct ?qid ?occupationQid ?gnd ?gndLabel ?gndId
where {
#
# occupation IDs in GND and Wikidata
values ( ?occupationGndId ?occupationQid ) {
( '4066533-1' 'Q188094' ) # economist
}
bind(uri(concat(str(gnd:), ?occupationGndId)) as ?occupationGnd)
#
# reach out to Wikidata endpoint and get all Wikidata items
# with GND that are humans w/o known occupation
service <https://query.wikidata.org/sparql> {
?wd wdt:P227 ?gndId ;
wdt:P31 wd:Q5 .
filter (not exists {
# binding for ?occupationQid is out of scope here!
?wd wdt:P106 <http://www.wikidata.org/entity/Q188094> .
}
)
# remove results with blank nodes ('unknown value')
# (otherwise result set on GND side is exploding)
filter(isLiteral(?gndId))
bind(strafter(str(?wd), str(wd:)) as ?qid)
}
#
# back on GND endpoint, ask for the occupation
bind(uri(concat(str(gnd:), ?gndId)) as ?gnd)
#
?gnd gndo:professionOrOccupation ?occupationGnd ;
gndo:preferredNameForThePerson ?gndLabel .
}