-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfix-thesaurusarray.ru
75 lines (68 loc) · 1.62 KB
/
fix-thesaurusarray.ru
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# This SPARQL update query will
#
# - add skos:broader relations that circumvent thesaurus arrays (up to 2 levels)
# - replace ?c2 skos:broader ?c1 with ?c1 skos:member ?c2 where ?c1 a isothes:ThesaurusArray
# - remove ?c1 a skos:Concept where ?c1 a isothes:ThesaurusArray
# - remove ?c1 skos:broader ?c2 where ?c1 a isothes:ThesaurusArray
#
# This is more efficiently done with SPARQL than with XQuery
#
# Usage with arq: update --update=fix-thesaurusarray.ru --data=humord.rdf.xml --dump > out.ttl
#
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX humord: <http://data.ub.uio.no/humord/>
PREFIX isothes: <http://purl.org/iso25964/skos-thes#>
INSERT
{ ?c1 skos:member ?c2 }
WHERE
{
?c2 skos:broader ?c1 .
?c1 a isothes:ThesaurusArray .
} ;
INSERT
{ ?c3 skos:broader ?c0 }
WHERE
{
?c3 a skos:Concept ;
skos:broader ?c2 .
?c2 a isothes:ThesaurusArray ;
skos:broader ?c1 .
?c1 a isothes:ThesaurusArray ;
skos:broader ?c0 .
?c0 a skos:Concept .
} ;
INSERT
{ ?c2 skos:broader ?c0 }
WHERE
{
?c2 a skos:Concept ;
skos:broader ?c1 .
?c1 a isothes:ThesaurusArray ;
skos:broader ?c0 .
?c0 a skos:Concept .
} ;
INSERT
{ ?c1 skos:broader ?c2 }
WHERE
{
?c2 skos:broader ?c1 .
?c1 a isothes:ThesaurusArray .
?c1 skos:broader ?c0 .
?c0 a skos:Concept .
} ;
DELETE
{ ?c2 skos:broader ?c1 }
WHERE
{
?c2 skos:broader ?c1 .
?c1 a isothes:ThesaurusArray .
} ;
DELETE
{ ?c1 rdf:type skos:Concept }
WHERE
{ ?c1 a isothes:ThesaurusArray } ;
DELETE
{ ?c1 skos:broader ?c2 }
WHERE
{ ?c1 a isothes:ThesaurusArray ; skos:broader ?c2 }