forked from zbw/sparql-queries
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wd_dbpedia_mapping.rq
39 lines (38 loc) · 1.38 KB
/
wd_dbpedia_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
# Create a STW - DBpedia mapping from Wikidata
#
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX dbr: <http://dbpedia.org/resource/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX schema: <http://schema.org/>
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/>
PREFIX wikibase: <http://wikiba.se/ontology#>
#
select ?stw ?skosRelation ?dbpedia ?item
where {
# get STW - Wikidata mapping, extend with mapping relation
service <https://query.wikidata.org/sparql> {
select ?stw ?item ?skosRelation ?stub
where {
?item p:P3911 ?statement .
?statement ps:P3911 ?stwId .
filter(isLiteral(?stwId))
# mapping relation
optional {
?statement pq:P4390 ?relation .
# URI of the equivalent skos property
?relation wdt:P2888 ?skosRelation .
}
bind(uri(concat('http://zbw.eu/stw/descriptor/', ?stwId)) as ?stw)
?page schema:about ?item ;
schema:isPartOf <https://en.wikipedia.org/> .
# returned page is url-encoded, dbpedia uses decode url
bind(strafter(wikibase:decodeUri(str(?page)), 'https://en.wikipedia.org/wiki/') as ?stub)
}
}
# compute dbpedia URI
bind(uri(concat(str(dbr:), ?stub)) as ?dbpedia)
}