forked from zbw/sparql-queries
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindustries_for_pm20_co_from_pm20.rq
55 lines (53 loc) · 1.76 KB
/
industries_for_pm20_co_from_pm20.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
46
47
48
49
50
51
52
53
54
# Get the industry and nace assignment from pm20
#
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX dct: <http://purl.org/dc/terms/>
PREFIX esco: <http://data.europa.eu/esco/model#>
PREFIX frapo: <http://purl.org/cerif/frapo/>
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 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 zbwext: <http://zbw.eu/namespaces/zbw-extensions/>
#
select ?pm20Id ?pm20 ?pm20Label ?qid ?naceCode ?industry ##(concat('Q', str( min(?industryId) )) as ?industryQid)
where {
hint:Query hint:optimizer "None" .
#
# all companies with country from PM20
service <https://zbw.eu/beta/sparql/pm20/query> {
?pm20 a zbwext:CompanyFolder ;
skos:prefLabel ?pm20Label ;
dct:identifier ?pm20Id .
optional {
?pm20 schema:industry ?industry .
filter(lang(?industry) = 'en')
}
optional {
?pm20 esco:hasNACECode ?naceCode .
}
}
# "main" items - exclude items linked with mapping relations
?statement ps:P4293 ?pm20Id .
?wd p:P4293 ?statement .
filter (not exists {
?statement pq:P4390 [] .
})
bind(strafter(str(?wd), str(wd:)) as ?qid)
#
# exclude items with already existing country
## filter(not exists {
## ?wd wdt:P17 [] .
## })
#
## optional {
## ?industryWd wdt:P297 ?countryCode .
## bind(xsd:integer(strafter(str(?industryWd), 'http://www.wikidata.org/entity/Q')) as ?industryId)
## }
}
##group by ?pm20Id ?pm20 ?pm20Label ?qid ?countryCode
##order by ?pm20Id $industryId