forked from zbw/sparql-queries
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd_category_doc_counts.rq
54 lines (52 loc) · 2.11 KB
/
add_category_doc_counts.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
# Aggregated document counts for all folders by category
#
PREFIX zbwext: <http://zbw.eu/namespaces/zbw-extensions/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX dct: <http://purl.org/dc/terms/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
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/>
#
select ?signature ?country ?countryLabel ?folderCount ?complete ?numberWorks ?accessibleOnline ?qsStatement
where {
{
select ?signature ?country ?countryLabel (str(?folderCnt) as ?folderCount) ?complete (str(sum(?total)) as ?totalCnt) (str(sum(?free)) as ?accessibleOnline)
where {
graph <http://zbw.eu/beta/geo/ng> {
values ( ?language ) {
( 'de' )
}
?country dct:identifier ?countryId ;
skos:notation ?signature ;
skos:prefLabel ?countryLabelLang ;
zbwext:foldersComplete ?complete ;
zbwext:shFolderCount ?folderCnt .
filter(lang(?countryLabelLang) = ?language)
bind(str(?countryLabelLang) as ?countryLabel)
}
?pm20 zbwext:country ?country .
?pm20 zbwext:freeDocCount ?free ;
zbwext:totalDocCount ?total .
}
group by ?country ?countryLabel ?signature ?folderCnt ?complete
}
service <https://query.wikidata.org/sparql> {
hint:Query hint:optimizer "None" .
?item p:P8483 ?statement .
?statement ps:P8483 ?signature .
filter(isLiteral(?signature))
#
# skip all items where one of the counts already exists
filter(not exists {
?statement (pq:P3740 | pq:5592) [] .
})
}
# since all digitized data up to 1960 has to be considered, almost all folders are incomplete.
# therefore, use 'unknown value' everywhere.
## bind(if(?complete = 'Y', str(?totalCnt), 'somevalue') as ?numberWorks)
bind( 'somevalue' as ?numberWorks)
bind(concat(strafter(str(?item), '/entity/'),'|P8483|"',?signature,
'"|P3740|', ?numberWorks, '|P5592|', ?accessibleOnline) as ?qsStatement)
}