-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmissing_gnd_id_for_viaf.rq
40 lines (40 loc) · 1.33 KB
/
missing_gnd_id_for_viaf.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
# Get GND ids for Wikidata pages without GND id, but having VIAF id,
# making use of VIAF sameAs data
#
# against viaf endpoint
#
PREFIX schema: <http://schema.org/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX zbwext: <http://zbw.eu/namespaces/zbw-extensions/>
#
# make sure that only one result per ?wdId is produced, ignore items with
# multiple ?viafIds or ?gndIds
select ?wdId (count(*) as ?count) (max(?viafId) as ?sourceId) (max(?gndId) as ?targetId)
where {
# all wikidata items with viaf id, which have no gnd id
service <https://query.wikidata.org/bigdata/namespace/wdq/sparql> {
?wd wdt:P31 wd:Q5 ;
wdt:P214 ?viafId .
# filter out blnak nodes (= "unknown value")
filter(!isBlank(?viafId))
filter(not exists {
?wd wdt:P227 [] .
})
}
bind(strafter(str(?wd), "http://www.wikidata.org/entity/") as ?wdId)
bind(uri(concat("http://viaf.org/viaf/", $viafId)) as ?viaf)
#
# of these, all which have gnd ids in viaf
?viaf schema:sameAs ?gnd
filter(contains(str(?gnd), "http://d-nb.info/gnd/"))
bind(strafter(str(?gnd), "http://d-nb.info/gnd/") as ?gndId)
#
# optionally, restrict to economists (gnd present in EconBiz)
graph <http://zbw.eu/beta/ebCount/ng> {
?gnd zbwext:econbizCount [] .
}
}
group by ?wdId
having (?count = 1)
limit 10