forked from zbw/sparql-queries
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathitem_by_pm20_id.rq
34 lines (34 loc) · 947 Bytes
/
item_by_pm20_id.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
# Items by pm20 folder id
#
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 wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
#
select ?pm20Id ?wd ?wdLabel ?relLabel
where {
values ( ?pm20Id) {
( 'co/072129' )
}
# get relevant statements
?statement ps:P4293 ?pm20Id .
optional {
?statement pq:P4390 ?rel .
?rel rdfs:label ?relLabelLang .
filter(lang(?relLabelLang) = 'en')
bind(str(?relLabelLang) as ?relLabel)
}
# get the item
?wd p:P4293 ?statement .
#
# get some label
bind(strafter(str(?wd), 'http://www.wikidata.org/entity/') as ?wdId)
optional {
?wd rdfs:label ?wdLabelLang .
filter(lang(?wdLabelLang) = 'en')
}
bind(coalesce(str(?wdLabelLang), ?wdId) as ?wdLabel)
}
order by ?relLabel