-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dimension relation validations #199
Changes from 12 commits
99bd903
56033a3
7dda5fc
7c58565
2051a36
792fdc0
c911e11
a41f716
e0971fd
35f7f7a
ee891f7
f514843
bb83580
49c2df2
a31482a
7cb9da8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
"cube-link": patch | ||
--- | ||
|
||
Improve validation of `meta:dimensionRelation`: | ||
|
||
1. Check that upper/lower bound has at most one `dcterms:type` | ||
2. Check that `meta:relatesTo` is actually a dimension |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
PREFIX dcterms: <http://purl.org/dc/terms/> | ||
@prefix relation: <https://cube.link/relation/> . | ||
@prefix meta: <https://cube.link/meta/> . | ||
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . | ||
@prefix cube: <https://cube.link/> . | ||
@prefix observation: <https://environment.ld.admin.ch/foen/nfi/observation/max_min_undefined> . | ||
@prefix sh: <http://www.w3.org/ns/shacl#> . | ||
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . | ||
@prefix schema: <http://schema.org/> . | ||
@base <https://example.org/> . | ||
|
||
<cube> a cube:Cube ; | ||
cube:observationConstraint <shape> ; | ||
cube:observationSet <observationSet> . | ||
|
||
<observationSet> cube:observation <observationA>, <observationB>, <observationC> . | ||
|
||
<observationA> a cube:Observation ; | ||
cube:observedBy <observer> ; | ||
<dimension> 4.9 ; | ||
<upperConfidence> 0.1 ; | ||
. | ||
|
||
<shape> a cube:Constraint ; | ||
sh:targetClass cube:Observation ; | ||
sh:closed true ; | ||
sh:property | ||
[ | ||
sh:path rdf:type ; | ||
sh:nodeKind sh:IRI ; | ||
sh:minCount 1 ; | ||
sh:maxCount 1 | ||
] ; | ||
sh:property | ||
[ | ||
sh:path cube:observedBy ; ; | ||
sh:nodeKind sh:IRI ; | ||
sh:minCount 1 ; | ||
sh:maxCount 1 | ||
] ; | ||
sh:property | ||
[ | ||
sh:datatype xsd:decimal ; | ||
sh:path <dimension> ; | ||
schema:name "dimension" ; | ||
sh:minCount 1 ; | ||
sh:maxCount 1 ; | ||
], | ||
[ | ||
sh:datatype xsd:decimal ; | ||
sh:path <upperConfidence> ; | ||
schema:name "upper confidence" ; | ||
sh:minCount 1 ; | ||
sh:maxCount 1 ; | ||
meta:dimensionRelation | ||
[ | ||
a relation:ConfidenceUpperBound ; | ||
dcterms:type "Confidence interval", "bogus" ; | ||
meta:relatesTo <dimension> ; | ||
] ; | ||
]; | ||
. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
@prefix sh: <http://www.w3.org/ns/shacl#> . | ||
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . | ||
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . | ||
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . | ||
@prefix schema: <http://schema.org/> . | ||
@prefix cube: <https://cube.link/> . | ||
|
||
_:report a sh:ValidationReport ; | ||
sh:result [ | ||
rdf:type sh:ValidationResult ; | ||
sh:resultSeverity sh:Violation ; | ||
sh:sourceConstraintComponent sh:MaxCountConstraintComponent ; | ||
sh:sourceShape [ | ||
sh:path <http://purl.org/dc/terms/type> ; | ||
sh:maxCount 1 ; | ||
] ; | ||
sh:focusNode _:b5 ; | ||
sh:resultPath <http://purl.org/dc/terms/type> ; | ||
sh:resultMessage "More than 1 values" ; | ||
] ; | ||
sh:conforms false . |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
@prefix dcterms: <http://purl.org/dc/terms/> . | ||
@prefix relation: <https://cube.link/relation/> . | ||
@prefix meta: <https://cube.link/meta/> . | ||
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . | ||
@prefix cube: <https://cube.link/> . | ||
@prefix observation: <https://environment.ld.admin.ch/foen/nfi/observation/max_min_undefined> . | ||
@prefix sh: <http://www.w3.org/ns/shacl#> . | ||
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . | ||
@prefix schema: <http://schema.org/> . | ||
@base <https://example.org/> . | ||
|
||
<cube> a cube:Cube ; | ||
cube:observationConstraint <shape> ; | ||
cube:observationSet <observationSet> . | ||
|
||
<observationSet> cube:observation <observationA>, <observationB>, <observationC> . | ||
|
||
<observationA> a cube:Observation ; | ||
cube:observedBy <observer> ; | ||
<dimension> 4.9 ; | ||
<upperConfidence> 0.1 ; | ||
. | ||
|
||
<shape> a cube:Constraint ; | ||
sh:targetClass cube:Observation ; | ||
sh:closed true ; | ||
sh:property | ||
[ | ||
sh:path rdf:type ; | ||
sh:nodeKind sh:IRI ; | ||
sh:minCount 1 ; | ||
sh:maxCount 1 | ||
] ; | ||
sh:property | ||
[ | ||
sh:path cube:observedBy ; ; | ||
sh:nodeKind sh:IRI ; | ||
sh:minCount 1 ; | ||
sh:maxCount 1 | ||
] ; | ||
sh:property | ||
[ | ||
sh:datatype xsd:decimal ; | ||
sh:path <dimension> ; | ||
schema:name "dimension" ; | ||
sh:minCount 1 ; | ||
sh:maxCount 1 ; | ||
], | ||
[ | ||
sh:datatype xsd:decimal ; | ||
sh:path <upperConfidence> ; | ||
schema:name "upper confidence" ; | ||
sh:minCount 1 ; | ||
sh:maxCount 1 ; | ||
meta:dimensionRelation | ||
[ | ||
a relation:ConfidenceUpperBound ; | ||
dcterms:type "Confidence interval" ; | ||
meta:relatesTo <non-dimension> ; | ||
] ; | ||
]; | ||
. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
@prefix sh: <http://www.w3.org/ns/shacl#> . | ||
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . | ||
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . | ||
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . | ||
@prefix schema: <http://schema.org/> . | ||
@prefix cube: <https://cube.link/> . | ||
|
||
_:report a sh:ValidationReport ; | ||
sh:result [ | ||
rdf:type sh:ValidationResult ; | ||
sh:resultSeverity sh:Violation ; | ||
sh:sourceConstraintComponent sh:NodeConstraintComponent ; | ||
sh:sourceShape [ | ||
sh:path sh:property ; | ||
sh:node <https://cube.link/shape/standalone-constraint-constraint#DimensionRelation> ; | ||
] ; | ||
sh:focusNode <https://example.org/shape> ; | ||
sh:resultPath sh:property ; | ||
sh:resultMessage "Value does not have shape <https://cube.link/shape/standalone-constraint-constraint#DimensionRelation>" ; | ||
sh:detail [ | ||
rdf:type sh:ValidationResult ; | ||
sh:resultSeverity sh:Violation ; | ||
sh:sourceConstraintComponent sh:MinCountConstraintComponent ; | ||
sh:sourceShape [ | ||
sh:path _:b675 ; | ||
sh:class cube:Constraint ; | ||
sh:minCount 1 ; | ||
sh:message "value of meta:relatesTo must be a cube dimension" ; | ||
] ; | ||
sh:focusNode _:b5 ; | ||
sh:resultPath _:b675 ; | ||
sh:resultMessage "value of meta:relatesTo must be a cube dimension" ; | ||
] ; | ||
sh:value _:b4 ; | ||
] ; | ||
sh:conforms false . | ||
|
||
_:b675 rdf:first <https://cube.link/meta/relatesTo> ; | ||
rdf:rest ( | ||
[ | ||
sh:inversePath sh:path ; | ||
] | ||
[ | ||
sh:inversePath sh:property ; | ||
] | ||
) . |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
PREFIX dcterms: <http://purl.org/dc/terms/> | ||
@prefix relation: <https://cube.link/relation/> . | ||
@prefix meta: <https://cube.link/meta/> . | ||
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . | ||
@prefix cube: <https://cube.link/> . | ||
@prefix observation: <https://environment.ld.admin.ch/foen/nfi/observation/max_min_undefined> . | ||
@prefix sh: <http://www.w3.org/ns/shacl#> . | ||
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . | ||
@prefix schema: <http://schema.org/> . | ||
@base <https://example.org/> . | ||
|
||
<cube> a cube:Cube ; | ||
cube:observationConstraint <shape> ; | ||
cube:observationSet <observationSet> . | ||
|
||
<observationSet> cube:observation <observationA>, <observationB>, <observationC> . | ||
|
||
<observationA> a cube:Observation ; | ||
cube:observedBy <observer> ; | ||
<dimension> 4.9 ; | ||
<upperConfidence> 0.1 ; | ||
<lowerConfidence> 0.15 ; | ||
. | ||
|
||
<shape> a cube:Constraint ; | ||
sh:targetClass cube:Observation ; | ||
sh:closed true ; | ||
sh:property | ||
[ | ||
sh:path rdf:type ; | ||
sh:nodeKind sh:IRI ; | ||
sh:minCount 1 ; | ||
sh:maxCount 1 | ||
] ; | ||
sh:property | ||
[ | ||
sh:path cube:observedBy ; ; | ||
sh:nodeKind sh:IRI ; | ||
sh:minCount 1 ; | ||
sh:maxCount 1 | ||
] ; | ||
sh:property | ||
[ | ||
sh:datatype xsd:decimal ; | ||
sh:path <dimension> ; | ||
schema:name "dimension" ; | ||
sh:minCount 1 ; | ||
sh:maxCount 1 ; | ||
], | ||
[ | ||
sh:datatype xsd:decimal ; | ||
sh:path <upperConfidence> ; | ||
schema:name "upper confidence" ; | ||
sh:minCount 1 ; | ||
sh:maxCount 1 ; | ||
meta:dimensionRelation | ||
[ | ||
a relation:ConfidenceUpperBound ; | ||
dcterms:type "Confidence interval" ; | ||
meta:relatesTo <dimension> ; | ||
] ; | ||
], | ||
[ | ||
sh:datatype xsd:decimal ; | ||
sh:path <lowerConfidence> ; | ||
schema:name "lower confidence" ; | ||
sh:minCount 1 ; | ||
sh:maxCount 1 ; | ||
meta:dimensionRelation | ||
[ | ||
a relation:ConfidenceLowerBound ; | ||
dcterms:type "Confidence interval" ; | ||
meta:relatesTo <dimension> ; | ||
] ; | ||
] ; | ||
. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
@prefix dcterms: <http://purl.org/dc/terms/> . | ||
@prefix : <https://cube.link/shape/standalone-constraint-constraint#> . | ||
@prefix dash: <http://datashapes.org/dash#> . | ||
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . | ||
|
@@ -8,6 +9,7 @@ | |
@prefix cube: <https://cube.link/> . | ||
@prefix meta: <https://cube.link/meta/> . | ||
@prefix qudt: <http://qudt.org/schema/qudt/> . | ||
@prefix relation: <https://cube.link/relation/> . | ||
|
||
# | ||
# This is the bare minimal SHACL shape for validating a Cube Constraint. | ||
|
@@ -179,17 +181,38 @@ | |
. | ||
|
||
:DimensionRelation a sh:NodeShape ; | ||
sh:property [ | ||
sh:property | ||
[ | ||
sh:path meta:dimensionRelation; | ||
sh:property [ | ||
sh:path meta:relatesTo; | ||
sh:nodeKind sh:IRI ; | ||
sh:minCount 1; | ||
sh:message "meta:dimensionRelation requires at least one meta:relatesTo"; | ||
] ; | ||
sh:property | ||
[ | ||
sh:path meta:relatesTo ; | ||
sh:nodeKind sh:IRI ; | ||
sh:minCount 1 ; | ||
sh:message "meta:dimensionRelation requires at least one meta:relatesTo" ; | ||
], | ||
[ | ||
sh:path | ||
( | ||
meta:relatesTo | ||
[ sh:inversePath sh:path ] | ||
[ sh:inversePath sh:property ] | ||
) ; | ||
sh:minCount 1 ; | ||
sh:class cube:Constraint ; | ||
sh:message "value of meta:relatesTo must be a cube dimension" ; | ||
] ; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With SHACL-SPARQL we would be able to check that the two dimensions actually belong to the same cube. As above, we merely verify that they the related dimension is use in a cube, not necessarily the same cube. That would potentially cause false-positive results if a graph contained multiple cubes. But since we typically only validate cubes individually, we should be covered There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems like a reasonable restriction. But I have an additional
The dimension which is related to should be a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Rdataflow @l00mi WDYT? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. LGTM |
||
] ; | ||
. | ||
|
||
:Confidende a sh:NodeShape ; | ||
tpluscode marked this conversation as resolved.
Show resolved
Hide resolved
|
||
sh:targetClass relation:ConfidenceLowerBound, relation:ConfidenceUpperBound ; | ||
sh:property | ||
[ | ||
sh:path dcterms:type ; | ||
sh:maxCount 1 ; | ||
] ; | ||
. | ||
|
||
# Testing proper rdf:list construction | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kronmar I'm a little creative here since this was not really discussed. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like reasonable checks