forked from zbw/sparql-queries
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmissing_property.rq
74 lines (73 loc) · 2.76 KB
/
missing_property.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# Prominent economists, as indicated by a certain property,
# lacking another propery (e.g., RePEc authors without a GND ID)
#
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX schema: <http://schema.org/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wd: <http://www.wikidata.org/entity/>
#
select ?wd ?wdLabel
(group_concat(distinct str(?life) ; separator = "; ") as ?wdLife)
?wdDescription
(group_concat(distinct str(?affiliation) ; separator = "; ") as ?wdAffiliations)
?lookup ('look up in authority' as ?lookupLabel)
where {
# configuration of the query:
# ?missingProperty - the wikidata authority property to add
# ?definingPropterty - the wikidata authority property which indicates
# relevance and defines the restricted list of items
# ?lookupURL - a URL fragment which can be used to search names in
# the authority file addressed by ?missingProperty
# (this can address an arbitrary web application)
# e.g., GND missing for TED speakers, lookup in SPARQL Lab GND endpoint
values ( ?missingProperty ?definingProperty ?lookupURL ) {
( wdt:P227 wdt:P2428 'http://zbw.eu/beta/sparql-lab/?endpoint=https://zbw.eu/beta/sparql/gnd/query&queryRef=https://api.github.com/repos/jneubert/sparql-queries/contents/gnd/search_n_link_person.rq&name=' )
}
# restrict the data to "occupation economist"
##?wd wdt:P106 wd:Q188094 .
#
# restrict to items with the property indicating relevance
?wd ?definingProperty [] .
#
# restrict to items without the missing property
filter(not exists {
?wd ?missingProperty [] .
})
#
# not all items have labels in English
optional {
?wd rdfs:label ?wdLabelLang
filter(lang(?wdLabelLang) = 'en')
bind(str(?wdLabelLang) as ?wdLabel)
}
# additional information for identifying the person
optional {
?wd wdt:P569 ?birthDate .
}
optional {
?wd wdt:P570 ?deathDate .
}
bind(concat(coalesce(str(year(?birthDate)), ''), coalesce(concat(' - ', str(year(?deathDate))), '')) as ?life)
#
optional {
?wd schema:description ?descriptionLang
filter(lang(?descriptionLang) = 'en')
bind(str(?descriptionLang) as ?wdDescription)
}
optional {
?wd wdt:P108/rdfs:label ?affiliationLang .
filter(lang(?affiliationLang) = 'en')
bind(str(?affiliationLang) as ?affiliation)
}
# build lookup link
bind(encode_for_uri(?wdLabel) as ?searchedName)
bind(strafter(str(?wd), str(wd:)) as ?wdId)
bind(uri(concat(?lookupURL, ?searchedName, '&wdId=', ?wdId)) as ?lookup)
#
# get site links (for sorting according to prominence)
?sitelink schema:about ?wd .
# filter out wikicite/wikicommons etc. links
filter(contains(str(?sitelink), 'wikipedia.org/'))
}
group by ?wd ?wdLabel ?wdDescription ?lookup
order by desc(count(distinct ?sitelink))