forked from zbw/sparql-queries
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpersons_missing_in_wikidata.rq
53 lines (52 loc) · 1.5 KB
/
persons_missing_in_wikidata.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
# Extract information for creating missing person items in Wikidata
#
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX zbwext: <http://zbw.eu/namespaces/zbw-extensions/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX schema: <http://schema.org/>
PREFIX gndo: <https://d-nb.info/standards/elementset/gnd#>
#
select ?pm20 ?pm20Label ?descrDe ?descrEn ?pm20Id ?classQid ?gndId ?birth ?death
where {
#
# determine for which entries we want to create items
{
?pm20 a zbwext:PersonFolder .
bind(strafter(str(?pm20), 'https://pm20.zbw.eu/folder/') as ?pm20Id)
} minus {
# minus all entries which are linked to WD items
service <https://query.wikidata.org/sparql> {
?wd wdt:P4293 ?pm20Id .
}
}
#
?pm20 skos:prefLabel ?pm20Label ;
zbwext:freeDocCount ?docCount .
#
# apply further restrictions:
# only if folder has documents
filter(?docCount > 0)
#
# Wikidata class - may be family
bind(if(contains(str(?pm20Label), '<Familie>'), 'Q8436','Q5') as ?classQid)
#
# description
optional {
?pm20 schema:hasOccupation ?descrDe .
}
bind(if(contains(str(?pm20Label), '<Familie>'), 'family','') as ?descrEn)
#
optional {
?pm20 gndo:gndIdentifier ?gndId .
}
# birth/death (only if not familly)
optional {
?pm20 schema:birthDate ?birth .
filter(!contains(?pm20Label, '<Familie>'))
}
optional {
?pm20 schema:deathDate ?death .
filter(!contains(?pm20Label, '<Familie>'))
}
}