This repository has been archived by the owner on May 17, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tarql.template
118 lines (109 loc) · 3.58 KB
/
main.tarql.template
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX {SUB}: <http://www.snik.eu/ontology/{SUB}/>
PREFIX meta: <http://www.snik.eu/ontology/meta/>
PREFIX apf: <http://jena.apache.org/ARQ/property#>
PREFIX ov: <http://open.vocab.org/terms/>
CONSTRUCT
{
<http://www.snik.eu/ontology/{SUB}> ov:defines ?s.
?s a owl:Class;
meta:subTopClass ?st;
rdfs:label ?lde, ?len;
?p ?o;
skos:definition ?d;
{SUB}:chapter ?ch;
meta:consolidated ?cons.
}
FROM <file:../main.csv>
WHERE
{
BIND (uri(concat(tarql:expandPrefix('{SUB}'),?SubjektUri)) AS ?s)
BIND (uri(concat(tarql:expandPrefix('meta'), ?SubjektTyp)) AS ?st)
BIND (STRLANG(?SubjektDe,"de") AS ?lde)
BIND (STRLANG(?SubjektEn,"en") AS ?len)
BIND (uri(tarql:expandPrefixedName(?Relation)) AS ?p)
BIND (uri(concat(tarql:expandPrefix('{SUB}'),?Objekt)) AS ?o)
BIND (STRLANG(?Definition,"de") AS ?d)
# Chapters should only consist of numbers and letters, so that the prefix:suffix syntax works.
# Replace other characters with '-'.
# Suffixes cannot start with numbers so add "ch-" in that case.
BIND (uri(concat(tarql:expandPrefix('{SUB}'),replace(replace(?Kapitel,"[^0-9A-Za-z]","-"),"^[^A-Za-z]","ch-$0"))) AS ?ch)
BIND(xsd:boolean(?Konsolidiert) as ?cons)
}
CONSTRUCT
{
?s skos:altLabel ?laen.
}
FROM <file:../main.csv>
WHERE
{
BIND (uri(concat(tarql:expandPrefix('{SUB}'),?SubjektUri)) AS ?s)
?laens apf:strSplit (?SubjektAltEn ";")
BIND (STRLANG(?laens,"en") AS ?laen)
FILTER(BOUND(?SubjektAltEn))
}
CONSTRUCT
{
?s skos:altLabel ?lade.
}
FROM <file:../main.csv>
WHERE
{
BIND (uri(concat(tarql:expandPrefix('{SUB}'),?SubjektUri)) AS ?s)
?lades apf:strSplit (?SubjektAltDe ";")
BIND (STRLANG(?lades,"de") AS ?lade)
FILTER(BOUND(?SubjektAltDe))
}
CONSTRUCT
{
?s {SUB}:page ?pd.
}
FROM <file:../main.csv>
WHERE
{
BIND (uri(concat(tarql:expandPrefix('{SUB}'),?SubjektUri)) AS ?s)
?pdd apf:strSplit (?SeiteDefinition ";")
BIND(xsd:positiveInteger(?pdd) as ?pd)
FILTER(BOUND(?SeiteDefinition) && ?pd > 0)
}
# Restrictions without page
CONSTRUCT
{
?s rdfs:subClassOf ?r.
?r
a owl:Restriction;
owl:onProperty ?rp;
?rt ?ro
.
}
FROM <file:../main.csv>
WHERE
{
FILTER (BOUND(?s) && BOUND(?rp) && BOUND(?ro) && BOUND(?rt))
BIND (uri(concat(tarql:expandPrefix('{SUB}'),?SubjektUri)) AS ?s)
BIND (uri(tarql:expandPrefixedName(?RestrictionOnProperty)) AS ?rp)
BIND (uri(concat(tarql:expandPrefix('{SUB}'),?RestrictionObject)) AS ?ro)
BIND (uri(concat(tarql:expandPrefix('owl'),?RestrictionType)) AS ?rt)
BIND (uri(concat(tarql:expandPrefix('{SUB}'),'restriction',md5(concat(str(?rp),str(?rt),str(?ro))))) AS ?r)
}
# Process restriction pages separately to make them optional. Otherwise apf:strSplit crashes.
CONSTRUCT
{
?r {SUB}:page ?pr.
}
FROM <file:../main.csv>
WHERE
{
FILTER (BOUND(?s) && BOUND(?rp) && BOUND(?ro) && BOUND(?rt) && BOUND(?SeiteRestriction))
BIND (uri(concat(tarql:expandPrefix('{SUB}'),?SubjektUri)) AS ?s)
BIND (uri(tarql:expandPrefixedName(?RestrictionOnProperty)) AS ?rp)
BIND (uri(concat(tarql:expandPrefix('{SUB}'),?RestrictionObject)) AS ?ro)
BIND (uri(concat(tarql:expandPrefix('owl'),?RestrictionType)) AS ?rt)
?prr apf:strSplit (?SeiteRestriction ";")
BIND(xsd:positiveInteger(?prr) as ?pr)
filter(?pr>0)
BIND (uri(concat(tarql:expandPrefix('{SUB}'),'restriction',md5(concat(str(?rp),str(?rt),str(?ro))))) AS ?r)
}