-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathskos.shacl.ttl
479 lines (457 loc) · 14.8 KB
/
skos.shacl.ttl
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
@prefix : <http://skohub.io/skohub-shacl> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
@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 dct: <http://purl.org/dc/terms/> .
# declare the skos prefix to use it in later SPARQL-based constraints
skos:
a owl:Ontology ;
owl:imports sh: ;
sh:declare [
sh:prefix "skos" ;
sh:namespace "http://www.w3.org/2004/02/skos/core#"^^xsd:anyURI ;
] .
# ConceptScheme
:ConceptSchemeShape
a sh:NodeShape ;
sh:targetClass skos:ConceptScheme ;
sh:property [
sh:path dct:title ;
sh:minCount 1;
sh:datatype rdf:langString ;
sh:message "Concept Scheme has no dct:title with a language tag!"
] ;
sh:property [
sh:path skos:hasTopConcept ;
sh:class skos:Concept ;
]
.
# Concept
:ConceptShape
a sh:NodeShape ;
sh:targetClass skos:Concept ;
sh:property [
sh:path skos:prefLabel ;
sh:minCount 1;
sh:datatype rdf:langString ;
sh:message "Each skos:Concept has to provide a skos:prefLabel"
] ;
sh:property [
sh:description "S14 A resource has no more than one value of skos:prefLabel per language tag." ;
sh:path skos:prefLabel ;
sh:datatype rdf:langString ;
sh:uniqueLang true ;
sh:message "Each skos:Concept has to provide a unique language for skos:prefLabel" ;
] ;
sh:property [
sh:path skos:altLabel ;
sh:datatype rdf:langString ;
sh:name "alt label" ;
sh:severity sh:Warning ;
] ;
# removed minCount because we check for disjointness here.
# min count is checked above
sh:property [
sh:path skos:prefLabel ;
sh:description "\"Constraint S13: skos:prefLabel, skos:altLabel and skos:hiddenLabel must be disjoint\"" ;
sh:disjoint skos:altLabel ;
sh:disjoint skos:hiddenLabel ;
# sh:minCount 1 ;
sh:name "pref label" ;
] ;
sh:property [
sh:path skos:altLabel ;
sh:description "\"Constraint S13: skos:prefLabel, skos:altLabel and skos:hiddenLabel must be disjoint\"" ;
sh:disjoint skos:hiddenLabel ;
sh:disjoint skos:prefLabel ;
sh:name "alt label" ;
] ;
sh:property [
sh:path skos:broader ;
sh:class skos:Concept ;
sh:name "broader" ;
sh:nodeKind sh:IRI ;
] ;
sh:property [
sh:path skos:definition ;
sh:datatype rdf:langString ;
sh:name "definition" ;
] ;
# duplicate of :Undocumented Concept?
sh:property [
sh:deactivated true ;
sh:path skos:definition ;
sh:minCount 1 ;
sh:name "definition" ;
sh:severity sh:Warning ;
sh:message "A definition should be given."
] ;
# with :NoLinkConceptScheme I can better check if there are concepts not linked to ConceptScheme
# sh:property [
# sh:path skos:inScheme ;
# sh:class skos:ConceptScheme ;
# sh:minCount 1 ;
# sh:name "in scheme" ;
# sh:nodeKind sh:IRI ;
# sh:severity sh:Warning ;
# ] ;
sh:property [
sh:path skos:narrower ;
sh:class skos:Concept ;
sh:name "narrower" ;
sh:nodeKind sh:IRI ;
] ;
# sh:property [
# sh:path skos:prefLabel ;
# sh:datatype rdf:langString ;
# sh:minCount 1 ;
# sh:message "One pref label per Concept should be given." ;
# sh:name "pref label" ;
# ] ;
# sh:property [
# sh:path skos:prefLabel ;
# sh:datatype rdf:langString ;
# sh:name "pref label" ;
# sh:severity sh:Warning ;
# ] ;
sh:property [
sh:path skos:related ;
sh:description "S27 skos:related is disjoint with the property skos:broaderTransitive." ;
sh:disjoint skos:broader ;
sh:disjoint skos:broaderTransitive ;
sh:disjoint skos:narrower ;
sh:disjoint skos:narrowerTransitive ;
sh:name "related" ;
] ;
sh:property [
sh:path skos:relatedMatch ;
sh:class skos:Concept ;
sh:name "related match" ;
sh:nodeKind sh:IRI ;
] ;
sh:property [
sh:path skos:relatedMatch ;
sh:disjoint skos:broadMatch ;
sh:disjoint skos:closeMatch ;
sh:disjoint skos:exactMatch ;
sh:disjoint skos:narrowMatch ;
sh:name "related match" ;
] ;
sh:property [
sh:path skos:topConceptOf ;
sh:class skos:ConceptScheme ;
sh:name "top concept of" ;
sh:nodeKind sh:IRI ;
] ;
.
:NoLinkToConceptScheme
a sh:NodeShape ;
sh:targetClass skos:Concept ;
sh:message "Orphaned concepts that are not linked to the ConceptScheme are not allowed." ;
sh:sparql [
a sh:SPARQLConstraint ;
sh:prefixes skos: ;
sh:select """
SELECT $this
WHERE {
$this a skos:Concept ;
FILTER (NOT EXISTS {
{$this skos:topConceptOf ?a }
UNION
{$this skos:inScheme ?a }
})
.
}""" ;
] ;
.
:OrphanConcepts
a sh:NodeShape ;
sh:targetClass skos:Concept ;
sh:severity sh:Warning ;
sh:sparql [
a sh:SPARQLConstraint ; # This triple is optional
sh:prefixes skos: ;
rdfs:comment "Orphan Concept" ;
sh:description "An orphan concept is a concept without any associative or hierarchical relations. It might have attached literals like e.g., labels, but is not connected to any other resource, lacking valuable context information. A controlled vocabulary that contains many orphan concepts is less usable for search and retrieval use cases, because, e.g., no hierarchical query expansion can be performed on search terms to find documents with more general content." ;
sh:message "The concept is not a top concept of a Concept Scheme and neither has a broader or related concept. If it is a topConcept link it with skos:topConceptOf. Otherwise use one of the other relations." ;
sh:severity sh:Info ;
sh:select """
SELECT $this
WHERE {
$this a skos:Concept .
FILTER NOT EXISTS {
?this skos:topConceptOf ?cs .
}
FILTER NOT EXISTS {
?this skos:broader | skos:broaderTransitive | skos:related ?other .
}
}""" ;
] ;
.
:AmbiguousNotatation
a sh:NodeShape ;
sh:severity sh:Warning ;
sh:targetClass skos:Concept ;
sh:sparql [
a sh:SPARQLConstraint ;
sh:prefixes skos: ;
rdfs:comment "Ambiguous Notation References" ;
sh:description "Concepts should not have identlical skos:notation literals." ;
sh:message "the concept has the same notation {$value} as {$path}" ;
sh:select """
SELECT $this (?other as ?path) ?value
WHERE {
$this skos:notation ?value .
?other skos:notation ?value .
FILTER ($this != ?other)
}""" ;
] ;
.
# I changed the query here, added skos:topConceptOf
:DuplicateNotatationWithinCS
a sh:NodeShape ;
sh:severity sh:Warning ;
sh:targetClass skos:Concept ;
sh:sparql [
sh:prefixes skos: ;
rdfs:comment "Duplicate Notation References within Concept Scheme" ;
sh:description "Concepts within the same Concept Scheme should not have identlical skos:notation literals." ;
sh:message "the concept has the same notation {$value} as {$path}" ;
sh:select """
SELECT $this (?other as ?path) ?value
WHERE {
$this skos:notation ?value .
?other skos:notation ?value .
$this skos:inScheme | skos:topConceptOf ?cs .
?other skos:inScheme | skos:topConceptOf ?cs .
FILTER ($this != ?other)
}""" ;
] ;
.
# I changed this query have to add again the replace part (TODO)
:EmptyLabels
a sh:NodeShape ;
sh:targetClass skos:Concept ;
sh:severity sh:Warning ;
rdfs:comment "Empty Labels" ;
sh:description "Labels also need to contain textual information to be useful, thus we find all SKOS labels with length 0 (after removing whitespaces)." ;
sh:message "Label with an empty value detected" ;
sh:sparql [
a sh:SPARQLConstraint ;
sh:prefixes skos: ;
sh:select """
SELECT $this ?path (?lab as ?value) (lang(?lab) as ?lang)
WHERE {
$this a skos:Concept .
{
SELECT $this ?path ?lab
WHERE{
$this skos:prefLabel | skos:altLabel | skos:hiddenLabel ?lab .
$this ?path ?lab .
bind ( strlen(?lab) as ?q)
FILTER ( ?q=0 )
}
}
}""" ;
] ;
.
# changed ?this to $this
# changed sh:message to provide more meaning
:OverlappingLabels
a sh:NodeShape ;
sh:deactivated true ;
sh:targetClass skos:Concept ;
sh:severity sh:Warning ;
sh:sparql [
a sh:SPARQLConstraint ;
sh:prefixes skos: ;
rdfs:comment "Overlapping Labels (concepts with the same label, independent of concept scheme )" ;
sh:description "This is a generalization of a recommendation in the SKOS primer, that “no two concepts have the same preferred lexical label in a given language when they belong to the same concept scheme”. This could indicate missing disambiguation information and thus lead to problems in autocompletion application." ;
sh:message "Overlapping Labels (there is concept '{$this}' with the same pref label in language '{$lang}' for concept '{$value}')" ;
sh:select """
SELECT $this (skos:prefLabel AS ?path) (?other as ?value) (lang(?pl) as ?lang)
WHERE {
?this skos:prefLabel ?pl .
?other skos:prefLabel ?opl .
?other a skos:Concept .
FILTER ($this != ?other && ?pl = ?opl)
}""" ;
] ;
.
# added | skos:topConceptOf in SPARQL query
# changed sh:message to provide more meaning
:OverlappingLabelsInSameConceptScheme
a sh:NodeShape ;
sh:targetClass skos:Concept ;
sh:severity sh:Warning ;
sh:sparql [
sh:prefixes skos: ;
rdfs:comment "Overlapping Labels in the same Concept Scheme (concepts with the same label in the same concept scheme)" ;
sh:message "Overlapping Labels in the same Concept Scheme (there is concept '{$this}' with the same pref label in language '{$lang}' for concept '{$value}'). Label: '{$pl}" ;
sh:select """
SELECT $this (skos:prefLabel AS ?path) (?other as ?value) (lang(?pl) as ?lang) $pl
WHERE {
?this skos:prefLabel ?pl .
?other skos:prefLabel ?opl .
?other a skos:Concept .
?this skos:inScheme | skos:topConceptOf ?cs .
?other skos:inScheme | skos:topConceptOf ?cs .
FILTER ($this != ?other && ?pl = ?opl)
}""" ;
] ;
.
:TopConceptsHavingBroader
a sh:NodeShape ;
sh:targetClass skos:Concept ;
sh:severity sh:Warning ;
sh:sparql [
a sh:SPARQLConstraint ;
sh:prefixes skos: ;
rdfs:comment "Top Concept Having Broader Concept" ;
sh:message "The top concept has a broader concept" ;
sh:select """
SELECT DISTINCT $this
WHERE {
$this skos:broader | skos:broaderTransitive ?other .
?this skos:topConceptOf ?cs .
}""" ;
] ;
.
:UndocumentedConcepts
a sh:NodeShape ;
sh:deactivated true ;
sh:targetClass skos:Concept ;
sh:severity sh:Warning ;
sh:sparql [
a sh:SPARQLConstraint ;
sh:prefixes skos: ;
rdfs:label "Undocumented Concept (no concept meaning description)" ;
sh:description """The SKOS \"standard\" defines a number of properties useful for documenting the meaning of the concepts in a thesaurus (section 7) also in a human-readable form. Intense use of these properties leads to a well-documented thesaurus which should also improve its quality.
Iteration over all concepts in the vocabulary and find those not using one of skos:note, skos:changeNote, skos:definition, skos:editorialNote, skos:example, skos:historyNote, or skos:scopeNote""" ;
sh:message "undocumented concept - none of the skos:notes is used to describe the meaning " ;
sh:select """
SELECT DISTINCT $this
WHERE {
$this a skos:Concept .
FILTER NOT EXISTS {?this skos:definition|skos:note|skos:example|skos:historyNote|skos:scopeNote ?note}
}""" ;
] ;
.
:DisjointConceptAndConceptScheme
a sh:NodeShape ;
sh:targetClass skos:Concept ;
sh:sparql [
sh:prefixes skos: ;
sh:message "A Concept cannot be also a ConceptScheme " ;
sh:select """
SELECT $this
WHERE {
$this a skos:ConceptScheme
}""" ;
] ;
.
:DisjointMappingRelations
a sh:NodeShape ;
rdfs:comment "Disjoint mapping relations" ;
rdfs:label "Disjoint mapping relations" ;
owl:versionInfo "EuVoc 1.1" ;
sh:property [
sh:path skos:closeMatch ;
sh:disjoint skos:broadMatch ;
sh:disjoint skos:exactMatch ;
sh:disjoint skos:narrowMatch ;
sh:disjoint skos:relatedMatch ;
sh:name "close match" ;
] ;
sh:property [
sh:path skos:exactMatch ;
sh:disjoint skos:broadMatch ;
sh:disjoint skos:closeMatch ;
sh:disjoint skos:narrowMatch ;
sh:disjoint skos:relatedMatch ;
sh:name "exact match" ;
] ;
sh:property [
sh:path skos:narrowMatch ;
sh:disjoint skos:broadMatch ;
sh:disjoint skos:closeMatch ;
sh:disjoint skos:exactMatch ;
sh:disjoint skos:relatedMatch ;
sh:name "narrow match" ;
] ;
sh:property [
sh:path skos:relatedMatch ;
sh:disjoint skos:broadMatch ;
sh:disjoint skos:closeMatch ;
sh:disjoint skos:exactMatch ;
sh:disjoint skos:narrowMatch ;
sh:name "related match" ;
] ;
sh:targetObjectsOf skos:broadMatch ;
sh:targetObjectsOf skos:closeMatch ;
sh:targetObjectsOf skos:exactMatch ;
sh:targetObjectsOf skos:narrowMatch ;
sh:targetObjectsOf skos:relatedMatch ;
sh:targetSubjectsOf skos:broadMatch ;
sh:targetSubjectsOf skos:closeMatch ;
sh:targetSubjectsOf skos:exactMatch ;
sh:targetSubjectsOf skos:narrowMatch ;
sh:targetSubjectsOf skos:relatedMatch ;
.
:SemanticRelations
rdf:type rdfs:Class ;
rdf:type sh:Shape ;
rdfs:comment "Semantic relations" ;
rdfs:label "Semantic relations" ;
rdfs:subClassOf rdfs:Resource ;
owl:versionInfo "EuVoc 1.1" ;
sh:sparql [
rdfs:comment "9.6.4. SKOS Concepts, Concept Collections and Semantic Relations" ;
sh:message "domain and range of SKOS semantic propoerties MUST be a skos:Concept . " ;
sh:select """
SELECT $this
WHERE {
FILTER NOT EXISTS{ $this a skos:Concept .}
}""" ;
] ;
sh:targetObjectsOf skos:broader ;
sh:targetObjectsOf skos:narrower ;
sh:targetObjectsOf skos:related ;
sh:targetSubjectsOf skos:broader ;
sh:targetSubjectsOf skos:narrower ;
sh:targetSubjectsOf skos:related ;
.
# SKOS Collections
skos:Collection
rdf:type sh:Shape ;
rdfs:comment "S19 and S20" ;
sh:sparql [
sh:message "The domain of semantic properties cannot be skos:Collection" ;
sh:select """
SELECT $this
WHERE {
?this skos:broader | skos:narrower | skos:related ?c .
}""" ;
] ;
sh:sparql [
sh:message "The range of semantic properties cannot be skos:Collection" ;
sh:select """
SELECT $this
WHERE {
?c skos:broader | skos:narrower | skos:related ?this .
}""" ;
] ;
sh:sparql [
sh:message "skos:Collection is disjoint with each of skos:Concept and skos:ConceptScheme." ;
sh:select """
SELECT $this
WHERE {
$this a ?type .
FILTER (?type NOT IN (skos:Concept, skos:ConceptScheme) )
}""" ;
] ;
.