forked from zbw/sparql-queries
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsubject_categories_for_wikidata.rq
53 lines (50 loc) · 1.56 KB
/
subject_categories_for_wikidata.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
# Extract information for creating category items in Wikidata
#
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 ?notationLong ?labelDe ?labelEn
('Systematikstelle des Pressearchiv 20. Jahrhundert' as ?descrDe)
('subject category of the 20th Century Press Archives' as ?descrEn)
(concat(?notation, ' ', ?labelDe) as ?aliasDe)
(concat(?notation, ' ', ?labelEn) as ?aliasEn)
?subjectCode
('Q92707903' as ?classQid)
where {
#
graph <http://zbw.eu/beta/subject/ng> {
?cat a skos:Concept ;
zbwext:notationLong ?notationLong ;
skos:notation ?notation .
bind(replace(?notation, ' ', '_') as ?subjectCode)
#
?cat skos:prefLabel ?labelLangDe .
filter(lang(?labelLangDe) = 'de')
bind(str(?labelLangDe) as ?labelDe)
optional {
?cat skos:prefLabel ?labelLangEn .
filter(lang(?labelLangEn) = 'en')
bind(str(?labelLangEn) as ?labelEn)
}
optional {
?cat zbwext:folderCount ?folderCount .
}
# restriction to real notations (no keywords)
filter(regex(?notationLong, "^[a-z]"))
# filter out special topics for SM
filter(!regex(?subjectCode, "^[a-z]0"))
filter(!strends(?notationLong, '-'))
# temporary restriction
filter(bound(?folderCount))
#
# filter out categories already existing in WD
} minus {
service <https://query.wikidata.org/sparql> {
?wd wdt:P8484 ?subjectCode .
}
}
}
order by ?notationLong
limit 100