forked from zbw/sparql-queries
-
Notifications
You must be signed in to change notification settings - Fork 0
/
numerous_synonyms.rq
61 lines (60 loc) · 1.95 KB
/
numerous_synonyms.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
57
58
59
60
# STW descriptors with numerous synonyms (possibly mapping to mulitple GND subject headings)
#
PREFIX zbwext: <http://zbw.eu/namespaces/zbw-extensions/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX dcterms: <http://purl.org/dc/terms/>
#
# aggregation of GND subject headings
select
?stw (sample(?stwLabel1) as ?stwLabel)
(sample(?id) as ?stwId)
(sample(?countSynonyms1) as ?countSynonyms)
(count(?foreign) as ?countGnd)
(sample(?synonyms1) as ?synonyms)
where {
# aggregation of synonyms
{
select ?stw (sample(?prefLabel) as ?stwLabel1) (count(?synonym) as ?countSynonyms1) (group_concat(?synonym;
separator = ' | ') as ?synonyms1)
where {
# nested select necessary for excluding duplicates _before_ concatenating
# (for highlighting in EconBiz, labels should not be lowercased)
select distinct ?stw ?prefLabel (str(?label) as ?synonym)
where {
# obtain gnd concepts via their mapping to STW
?stw a zbwext:Descriptor ;
skos:prefLabel ?prefLabel .
filter(lang(?prefLabel) = 'de')
# restrict to concepts with GND mapping
?stw skos:exactMatch ?foreign .
?foreign dcterms:isPartOf <http://zbw.eu/stw/mapping/gnd/target> .
{
# include all labels from STW
{
?stw skos:prefLabel ?label
}
UNION
{
?stw skos:altLabel ?label
}
# include labels from matching concepts in other thesauri
UNION
{
?stw skos:exactMatch/skos:prefLabel ?label
}
UNION
{
?stw skos:exactMatch/skos:altLabel ?label
}
}
}
}
group by ?stw
having (?countSynonyms1 > 15)
}
?stw skos:exactMatch ?foreign .
?foreign dcterms:isPartOf <http://zbw.eu/stw/mapping/gnd/target> .
bind(strafter(str(?stw), 'stw/descriptor/') as ?id)
}
group by ?stw
order by desc(sample(?countSynonyms1))