forked from zbw/sparql-queries
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcount_country_code.rq
43 lines (41 loc) · 1.35 KB
/
count_country_code.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
# Count folders by ISO 3166-1 alpha-2 country code
# (currently only applies to CompanyFolder)
#
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX frapo: <http://purl.org/cerif/frapo/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX schema: <http://schema.org/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX zbwext: <http://zbw.eu/namespaces/zbw-extensions/>
#
select ?count (str(?cnt) as ?countLabel) ?code ?country
where {
{
select (count(distinct ?pm20) as ?cnt) ?code
where {
?pm20 a zbwext:Pm20Folder ;
frapo:hasCountryCode ?code .
#
# restrict to folders with online documents
?pm20 zbwext:freeDocCount [] .
}
group by ?code
}
#
# add country label from Wikidata
service <https://query.wikidata.org/sparql> {
values ( ?language ) {
( "de" )
}
?wd wdt:P297 ?code ;
rdfs:label ?labelLang .
filter(lang(?labelLang) = ?language)
}
bind(str(?labelLang) as ?country)
#
bind(uri(concat('http://zbw.eu/beta/sparql-lab/?endpoint=https://zbw.eu/beta/sparql/pm20/query',
'&queryRef=https://api.github.com/repos/zbw/sparql-queries/contents/pm20/folder_by_country_code.rq',
'&language=', ?language, '&code=', ?code , '&country=', encode_for_uri(?country))) as ?count)
}
order by desc(?cnt)