-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathinexact_wikidata_mapping.rq
44 lines (43 loc) · 1.64 KB
/
inexact_wikidata_mapping.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
# Get all in-exact mappings from Wikidata to STW (with link for search in Wikidata)
#
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
#
select distinct ?wd ?wdLabel ?relation ?relationLabel ?stw ?stwLabel ?searchLink ('Search in Wikidata' as ?searchLinkLabel)
where {
service <https://query.wikidata.org/bigdata/namespace/wdq/sparql> {
# all existing STW IDs and relations for the item
?wd p:P3911 ?statement .
# any mapping relation
?statement pq:P4390 ?relation ;
ps:P3911 ?stwId .
filter(isLiteral(?stwId))
#
# restrict to in-exact mappings
filter(?relation != wd:Q39893449)
#
# get label for the wd item, if exists
optional {
?wd rdfs:label ?label .
filter(lang(?label) = 'en')
bind(str(?label) as ?wdLabel)
}
?relation rdfs:label ?relationLabelLang .
filter(lang(?relationLabelLang) = 'en')
bind(str(?relationLabelLang) as ?relationLabel)
}
# look up STW descriptors and labels
bind(uri(concat('http://zbw.eu/stw/descriptor/', ?stwId)) as ?stw)
?stw skos:prefLabel ?stwLabelLang .
filter(lang(?stwLabelLang) = 'en')
bind(str(?stwLabelLang) as ?stwLabel)
#
# create search link
bind (uri(concat('https://www.wikidata.org/w/index.php?title=Special:Search&fulltext=1&search=', replace(?stwLabel, ' ', '%20'))) as ?searchLink)
}
order by ?wdLabel desc(?relation)