forked from zbw/sparql-queries
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlookup_by_gnd.rq
41 lines (40 loc) · 1.38 KB
/
lookup_by_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
40
# Lookup wikidata URI by GND id, show label, language-specific wikipedia site link and link to the SQUID browser
#
# Must use SPARQL GET request (wikidata does not support POST -
# see https://phabricator.wikimedia.org/T112151)
#
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX v: <http://www.wikidata.org/prop/statement/>
PREFIX q: <http://www.wikidata.org/prop/qualifier/>
PREFIX schema: <http://schema.org/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
#
select ?gndId ?wd ?wdLabel ?squid (?wdLabel as ?squidLabel) ?sitelink
where {
# GND ID of John Maynard Keynes and of Currency union
values ( ?gndId ) {
( '118561804' )
( '4188829-7' )
}
values ( ?language ) {
( 'en' )
}
# look up wikidata items and labels
?wd wdt:P227 ?gndId ;
rdfs:label ?wdLabel .
#
# get site links (only from de/en wikipedia sites)
?sitelink schema:about ?wd ;
schema:inLanguage ?language .
#
# create link to squid-Browser
bind(uri(concat('http://tools.wmflabs.org/sqid/#/view?id=', strafter(str(?wd), '/entity/'), '&lang=de')) as ?squid)
filter (contains(str(?sitelink), 'wikipedia'))
#
# restrict languages
# filter (lang(?wdLabel) = ?language && ?language in ('en', 'de'))
filter (lang(?wdLabel) = ?language)
}