SHACL validation checks - OpenCS-ontology/OpenCS GitHub Wiki

Introduction

This page represents the brief description of all the validation checks currently defined in the shacl_constraints.ttl file located in the main OpenCS repository. These checks are performed each time a validation workflow is run. They are performed on all the entries of the OpenCS graph. More information about the Shapes Constraint Language (SHACL) may be found on the official documentation page.

Validation checks

All the subsequent sub-sections of this section contain descriptions of the various SHACL checks performed on OpenCS graph.

Single PrefLabel Per Language Rule

Rule stating that entities inside the OpenCS graph that are of type skos:Concept must have only one unique Language label for the property skos:prefLabel. This is ensured by utilizing the sh:uniqueLang SHACL property and setting it to true.

ocsh:SinglePrefLabelPerLanguageRule
	a sh:NodeShape ;
	sh:targetClass skos:Concept  ;
    sh:message "Concept needs to have at most one skos:prefLabel per language" ;
	sh:property [
		sh:path skos:prefLabel ;
		sh:uniqueLang true ;
	] .

Single Definition Per Language Rule

Rule stating that nodes inside the OpenCS graph that are of type skos:Concept must have only one unique Language label for the property skos:definition. This is ensured by using the sh:uniqueLang SHACL property and setting it to true.

ocsh:SingleDefinitionPerLanguageRule
	a sh:NodeShape ;
	sh:targetClass skos:Concept  ;
    sh:message "Concept needs to have at most one skos:definition per language" ;
	sh:property [
		sh:path skos:definition ;
		sh:uniqueLang true ;
	] .

Root Rule

A simple "helper" rule checking if node is the root of the graph. Root of the graph is understood as ocs:C1. The check is done by utilizing the sh:in property.

ocsh:RootRule
    a sh:NodeShape ;
    sh:in (ocs:C1) .

Non Roots Have Single Broader Rule

Rule stating that an entity of class skos:Concept either has at least one skos:broader property, or is a root node (see Root Rule). This is done by utilizing sh:or property. Checking if a node has at least one skos:broader property is done by setting sh:minCount to 1.

ocsh:NonRootsHaveSingleBroaderRule
    a sh:NodeShape ;
	sh:targetClass skos:Concept  ;
    sh:message "Concepts other than Computer Science need broader concept" ;
    sh:or (
		[
			sh:property [
				sh:path skos:broader ;
				sh:minCount 1 ;
			]
		]
		[
		    sh:node ocsh:RootRule ;
		]
	) .

No Cycles Rule

Rule stating that there should be no cycles in the skos:broader hierarchy. This is done by ensuring that a concept on the hierarchical path from a given concept does not contain the same skos:prefLabel property. For this purpose, sh:disjoint SHACL property is used.

ocsh:NoCyclesRule
    a sh:NodeShape ;
	sh:targetClass skos:Concept  ;
    sh:message "The skos:broader hierarchy should not contain cycles" ;
	sh:property [
		sh:path  ([sh:oneOrMorePath skos:broader] skos:prefLabel) ;
		sh:disjoint skos:prefLabel ;
	] .

Related Broader Disjoint

Rule stating that entities that already possess a property skos:broader towards another entity, should not also possess a skos:related property towards that entity. This statemen is transitive with regards to the skos:broader property. The check is done by utilizing the sh:disjoint property. The severity of this validation check is set to a sh:Warning, meaning that failing this check will not fail the whole validation process (but may in the future).

ocsh:RelatedBroaderDisjoint 
	a sh:NodeShape ;
	sh:targetClass skos:Concept ;
	sh:message "Hierarchical links (skos:broader, transitively) and associative links (skos:related) should be disjoint" ;
	sh:property [
		sh:severity sh:Warning ;
		sh:path [ sh:oneOrMorePath skos:broader ; ] ;
		sh:disjoint skos:related ;
	] .