forked from zbw/sparql-queries
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmultiple_pm20_co.rq
46 lines (45 loc) · 1.25 KB
/
multiple_pm20_co.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
# Items with multiple PM20 co entries (narrow match excluded)
#
PREFIX hint: <http://www.bigdata.com/queryHints#>
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 ?count ?wd ?wdLabel
where {
{
select ?wd (count(?statement) as ?count)
where {
hint:Query hint:optimizer "None" .
#
# all WD items for this subset
?wd p:P4293 ?statement .
?statement ps:P4293 ?pm20Id .
filter(strstarts(?pm20Id, 'co/'))
#
# exclude narrow matches
filter(not exists {
?statement pq:P4390 wd:Q39893967 .
}
)
# exclude related matches
filter(not exists {
?statement pq:P4390 wd:Q39894604 ;
}
)
}
group by ?wd
having (?count > 1)
}
# get other fields for display and for the statement
bind(strafter(str(?wd), 'http://www.wikidata.org/entity/') as ?wdId)
optional {
?wd rdfs:label ?wdLabelLang .
filter(lang(?wdLabelLang) = 'en')
bind(str(?wdLabelLang) as ?wdLabel)
}
}
order by ?wdId