forked from zbw/sparql-queries
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmissing_pm20_id_via_gnd.rq
40 lines (39 loc) · 1.32 KB
/
missing_pm20_id_via_gnd.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
# Get missing PM20 IDs for WD items with known GND ID
#
PREFIX dct: <http://purl.org/dc/terms/>
PREFIX gndo: <https://d-nb.info/standards/elementset/gnd#>
PREFIX hint: <http://www.bigdata.com/queryHints#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
#
select ?gndId ?pm20 ?pm20Label ?wd ?wdLabel ?qsStatement
where {
# query optimizer can make some queries so slow, that they hit the timeout
hint:Query hint:optimizer "None" .
#
# Reach out to PM20 endpoint
service <https://zbw.eu/beta/sparql/pm20/query> {
?pm20 gndo:gndIdentifier ?gndId ;
dct:identifier ?pm20Id ;
skos:prefLabel ?pm20Label .
}
# back in Wikidata: items with matching gndId
?wd wdt:P227 ?gndId .
#
# skip item which are already linked to PM20
filter(not exists {
?wd wdt:P4293 [] .
}
)
# for informational purposes, add label
optional {
?wd rdfs:label ?wdLabelLang .
filter(lang(?wdLabelLang) = 'de')
bind(str(?wdLabelLang) as ?wdLabel)
}
# construct QS input
bind(strafter(str(?wd), 'http://www.wikidata.org/entity/') as ?wdId)
bind(concat(?wdId, '|P4293|"', ?pm20Id, '"|S248|Q36948990|S1476|en:"Via P227 lookup with GND value from PM20 folder"') as ?qsStatement)
}
order by ?pm20Label