forked from zbw/sparql-queries
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfolder_names_qs.rq
57 lines (56 loc) · 1.82 KB
/
folder_names_qs.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
55
56
# Folder names qs input for folders connected to WD items
#
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 wds: <http://www.wikidata.org/entity/statement/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX zbwext: <http://zbw.eu/namespaces/zbw-extensions/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX dct: <http://purl.org/dc/terms/>
#
select ?qsStatement ?item ?itemLabel ?pm20 (?prefLabel as ?pm20Label)
where {
# get ids and labels from WD endpoint
service <https://query.wikidata.org/sparql> {
# do not create for sh and wa, because that would be redundant (labels)
values ( ?type ) {
( 'pe' )
( 'co' )
}
# statments about pm20Id
?statement ps:P4293 ?pm20Id .
filter(isLiteral(?pm20Id))
filter(strstarts(?pm20Id, ?type))
#
# skip all statements where the folder name already exists
filter(not exists {
?statement pq:P1810 [] .
})
# according items
?item p:P4293 ?statement .
#
# create a WD label (for intellectual validation)
optional {
?item rdfs:label ?itemLabelEn .
filter(lang(?itemLabelEn) = 'en')
}
optional {
?item rdfs:label ?itemLabelDe .
filter(lang(?itemLabelDe) = 'de')
}
bind(str(coalesce(?itemLabelEn, ?itemLabelDe, strafter(str(?item), '/entity/'))) as ?itemLabel)
}
#
# get folder names
?pm20 dct:identifier ?pm20Id ;
skos:prefLabel ?prefLabel .
#
# construct QS statement
bind(concat(strafter(str(?item), str(wd:)),'|P4293|"', ?pm20Id,
'"|P1810|"', ?prefLabel, '"') as ?qsStatement)
}
order by ?type ?pm20Label