Skip to content

Commit

Permalink
Refactor into separate files for SPIN and SHACL
Browse files Browse the repository at this point in the history
Not yet fully tested
  • Loading branch information
Simon Cox committed Jun 11, 2018
1 parent 7a76d1c commit 1a9b2bd
Show file tree
Hide file tree
Showing 4 changed files with 1,060 additions and 1,013 deletions.
17 changes: 13 additions & 4 deletions proposals/ssn-extensions/rdf/ssn-ext-examples.ttl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# baseURI: http://example.org/ssn-ext-examples
# imports: http://www.w3.org/ns/ssn-ext
# imports: http://www.w3.org/ns/ssn-ext/
# prefix: ssn-ext-examples

@prefix dcterms: <http://purl.org/dc/terms/> .
Expand Down Expand Up @@ -30,9 +30,8 @@
sosa:hasResult <http://example.org/r99> ;
sosa:resultTime "2018-03-10T15:12:00+10:00"^^xsd:dateTime ;
.
<http://example.org/OC1>
<http://example.org/OC0>
rdf:type ssn-ext:ObservationCollection ;
sosa:hasFeatureOfInterest <http://example.org/Sample_1> ;
sosa:madeBySensor <http://example.org/s4> ;
sosa:observedProperty <http://example.org/op2> ;
sosa:phenomenonTime [
Expand All @@ -43,8 +42,18 @@
] ;
] ;
sosa:usedProcedure <http://example.org/p3> ;
ssn-ext:hasMember <http://example.org/OC1> ;
ssn-ext:hasMember <http://example.org/OC2> ;
.
<http://example.org/OC1>
rdf:type ssn-ext:ObservationCollection ;
sosa:hasFeatureOfInterest <http://example.org/Sample_1> ;
ssn-ext:hasMember <http://example.org/O2> ;
ssn-ext:hasMember <http://example.org/O3> ;
.
<http://example.org/OC2>
rdf:type ssn-ext:ObservationCollection ;
sosa:hasFeatureOfInterest <http://example.org/Sample_2> ;
ssn-ext:hasMember <http://example.org/O4> ;
ssn-ext:hasMember <http://example.org/O5> ;
.
Expand Down Expand Up @@ -88,5 +97,5 @@
dcterms:created "2018-03-10"^^xsd:date ;
dcterms:creator <http://orcid.org/0000-0002-3884-3420> ;
rdfs:comment "Small dataset to test SPIN rules in ssn-ext" ;
owl:imports <http://www.w3.org/ns/ssn-ext> ;
owl:imports ssn-ext: ;
.
175 changes: 175 additions & 0 deletions proposals/ssn-extensions/rdf/ssn-ext-shacl.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
# baseURI: http://www.w3.org/ns/ssn-ext/shacl/
# imports: http://datashapes.org/dash
# imports: http://www.w3.org/ns/ssn-ext/
# prefix: ssn-shacl

@prefix dct: <http://purl.org/dc/terms/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix sosa: <http://www.w3.org/ns/sosa/> .
@prefix ssn: <http://www.w3.org/ns/ssn/> .
@prefix ssn-ext: <http://www.w3.org/ns/ssn-ext/> .
@prefix ssn-shacl: <http://www.w3.org/ns/ssn-ext/shacl/> .
@prefix time: <http://www.w3.org/2006/time#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

sosa:Observation
rdf:type sh:NodeShape ;
sh:rule ssn-shacl:FOI ;
sh:rule ssn-shacl:procedure ;
sh:rule ssn-shacl:property ;
sh:rule ssn-shacl:ptime ;
sh:rule ssn-shacl:rtime ;
sh:rule ssn-shacl:sensor ;
sh:rule ssn-shacl:uFOI ;
.
ssn-ext:ObservationCollection
rdf:type sh:NodeShape ;
sh:rule ssn-shacl:FOI ;
sh:rule ssn-shacl:procedure ;
sh:rule ssn-shacl:property ;
sh:rule ssn-shacl:ptime ;
sh:rule ssn-shacl:rtime ;
sh:rule ssn-shacl:sensor ;
sh:rule ssn-shacl:uFOI ;
.
ssn-shacl:
rdf:type owl:Ontology ;
owl:imports <http://datashapes.org/dash> ;
owl:imports ssn-ext: ;
owl:versionInfo "Created with TopBraid Composer" ;
sh:declare [
rdf:type sh:PrefixDeclaration ;
sh:namespace "http://www.w3.org/ns/sosa/"^^xsd:anyURI ;
sh:prefix "sosa " ;
] ;
sh:declare [
rdf:type sh:PrefixDeclaration ;
sh:namespace "http://www.w3.org/ns/ssn-ext/"^^xsd:anyURI ;
sh:prefix "ssn-ext" ;
] ;
.
ssn-shacl:FOI
rdf:type sh:SPARQLRule ;
sh:construct """CONSTRUCT {
?this sosa:hasFeatureOfInterest ?foi .
}
WHERE {
NOT EXISTS {
?this sosa:hasFeatureOfInterest ?x .
} .
?oc ssn-ext:hasMember ?this .
?oc sosa:hasFeatureOfInterest ?foi .
}""" ;
sh:prefixes sosa: ;
sh:prefixes ssn-ext: ;
.
ssn-shacl:procedure
rdf:type sh:SPARQLRule ;
sh:construct """CONSTRUCT {
?this sosa:usedProcedure ?pr .
}
WHERE {
NOT EXISTS {
?this sosa:usedProcedure ?x .
} .
?oc ssn-ext:hasMember ?this .
?oc sosa:usedProcedure ?pr .
}""" ;
sh:prefixes sosa: ;
sh:prefixes ssn-ext: ;
.
ssn-shacl:property
rdf:type sh:SPARQLRule ;
sh:construct """CONSTRUCT {
?this sosa:observedProperty ?op .
}
WHERE {
NOT EXISTS {
?this sosa:observedProperty ?x .
} .
?oc ssn-ext:hasMember ?this .
?oc sosa:observedProperty ?op .
}""" ;
sh:prefixes sosa: ;
sh:prefixes ssn-ext: ;
.
ssn-shacl:ptime
rdf:type sh:SPARQLRule ;
sh:construct """CONSTRUCT {
?this sosa:phenomenonTime ?pt .
}
WHERE {
?oc ssn-ext:hasMember ?this .
?oc sosa:phenomenonTime ?pt .
NOT EXISTS {
?this sosa:phenomenonTime ?x .
} .
}""" ;
sh:prefixes sosa: ;
sh:prefixes ssn-ext: ;
.
ssn-shacl:rtime
rdf:type sh:SPARQLRule ;
sh:construct """CONSTRUCT {
?this sosa:resultTime ?rt .
}
WHERE {
NOT EXISTS {
?this sosa:resultTime ?x .
} .
?oc ssn-ext:hasMember ?this .
?oc sosa:resultTime ?rt .
}""" ;
sh:prefixes sosa: ;
sh:prefixes ssn-ext: ;
.
ssn-shacl:sensor
rdf:type sh:SPARQLRule ;
sh:construct """CONSTRUCT {
?this sosa:madeBySensor ?se .
}
WHERE {
NOT EXISTS {
?this sosa:madeBySensor ?x .
} .
?oc ssn-ext:hasMember ?this .
?oc sosa:madeBySensor ?se .
}""" ;
sh:prefixes sosa: ;
sh:prefixes ssn-ext: ;
.
ssn-shacl:uFOI
rdf:type sh:SPARQLRule ;
sh:construct """CONSTRUCT {
?this ssn-ext:hasUltimateFeatureOfInterest ?foi .
}
WHERE {
?this a sosa:Observation .
NOT EXISTS {
?this ssn-ext:hasUltimateFeatureOfInterest ?x .
} .
OPTIONAL {
?this sosa:hasFeatureOfInterest/(sosa:isSampleOf)* ?foi1 .
NOT EXISTS {
?foi1 sosa:isSampleOf ?y3 .
} .
} .
OPTIONAL {
?oc ssn-ext:hasMember ?this .
?oc ssn-ext:hasUltimateFeatureOfInterest ?foi2 .
} .
OPTIONAL {
?oc ssn-ext:hasMember ?this .
?oc sosa:hasFeatureOfInterest/(sosa:isSampleOf)* ?foi3 .
NOT EXISTS {
?foi3 sosa:isSampleOf ?y3 .
} .
} .
BIND (COALESCE(?foi1, ?foi2, ?foi3) AS ?foi) .
}""" ;
sh:prefixes sosa: ;
sh:prefixes ssn-ext: ;
.
Loading

0 comments on commit 1a9b2bd

Please sign in to comment.