Skip to content

Instantly share code, notes, and snippets.

@ajnelson-nist
Last active January 17, 2024 02:55
Show Gist options
  • Save ajnelson-nist/67a126996c8c944246cb6365cc29d816 to your computer and use it in GitHub Desktop.
Save ajnelson-nist/67a126996c8c944246cb6365cc29d816 to your computer and use it in GitHub Desktop.
pySHACL-Issue-220
.venv.done.log
venv

This Gist was written to support discussion on pySHACL Issue 220.

Usage

Run make -k check; or, run ./Makefile.

To focus the view on one test, run, e.g., make check-2.

@prefix ex: <http://example.org/ontology/> .
@prefix kb: <http://example.org/kb/> .
@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 xsd: <http://www.w3.org/2001/XMLSchema#> .
kb:thing-PASS-2
a
ex:ThingC ,
ex:ThingE
;
rdfs:comment "This should raise no validation results."@en ;
.
@prefix ex: <http://example.org/ontology/> .
@prefix kb: <http://example.org/kb/> .
@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 xsd: <http://www.w3.org/2001/XMLSchema#> .
kb:thing-PASS-1
a ex:ThingA ;
rdfs:comment "This should raise no validation results."@en ;
.
kb:thing-PASS-2
a
ex:ThingC ,
ex:ThingE
;
rdfs:comment "This should raise no validation results."@en ;
.
kb:thing-XFAIL-1
a ex:OneXorThing ;
rdfs:comment "This should raise a validation result, due to not being more specifically a ThingA or ThingB as the SHACL requires when reviewing the OWL disjoint union definition of OneXorThing."@en ;
.
kb:thing-XFAIL-2
a ex:ThingC ;
rdfs:comment "This should raise a validation result, due to not being a ThingE or ThingF as the SHACL requires when reviewing the entailed superclass TwoXorThing."@en ;
.

NIST Software Licensing Statement

NIST-developed software is provided by NIST as a public service. You may use, copy, and distribute copies of the software in any medium, provided that you keep intact this entire notice. You may improve, modify, and create derivative works of the software or any portion of the software, and you may copy and distribute such modifications or works. Modified works should carry a notice stating that you changed the software and should note the date and nature of any such change. Please explicitly acknowledge the National Institute of Standards and Technology as the source of the software.

NIST-developed software is expressly provided "AS IS." NIST MAKES NO WARRANTY OF ANY KIND, EXPRESS, IMPLIED, IN FACT, OR ARISING BY OPERATION OF LAW, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND DATA ACCURACY. NIST NEITHER REPRESENTS NOR WARRANTS THAT THE OPERATION OF THE SOFTWARE WILL BE UNINTERRUPTED OR ERROR-FREE, OR THAT ANY DEFECTS WILL BE CORRECTED. NIST DOES NOT WARRANT OR MAKE ANY REPRESENTATIONS REGARDING THE USE OF THE SOFTWARE OR THE RESULTS THEREOF, INCLUDING BUT NOT LIMITED TO THE CORRECTNESS, ACCURACY, RELIABILITY, OR USEFULNESS OF THE SOFTWARE.

You are solely responsible for determining the appropriateness of using and distributing the software and you assume all risks associated with its use, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and the unavailability or interruption of operation. This software is not intended to be used in any situation where a failure could cause risk of injury or damage to property. The software developed by NIST employees is not subject to copyright protection within the United States.

#!/usr/bin/make -k -f
# Portions of this file contributed by NIST are governed by the
# following statement:
#
# This software was developed at the National Institute of Standards
# and Technology by employees of the Federal Government in the course
# of their official duties. Pursuant to Title 17 Section 105 of the
# United States Code, this software is not subject to copyright
# protection within the United States. NIST assumes no responsibility
# whatsoever for its use by other parties, and makes no guarantees,
# expressed or implied, about its quality, reliability, or any other
# characteristic.
#
# We would appreciate acknowledgement if the software is used.
SHELL := /bin/bash
all: check
check: \
check-1 \
check-2 \
check-3 \
check-4
.venv.done.log:
python3 -m venv venv
source venv/bin/activate \
&& pip install pyshacl
touch $@
check-1: .venv.done.log
source venv/bin/activate \
&& pyshacl \
--metashacl \
--ont-graph owl-REPRODUCTION.ttl \
--shacl sh-REPRODUCTION-1.ttl \
kb-REPRODUCTION-1.ttl
check-2: .venv.done.log
source venv/bin/activate \
&& pyshacl \
--metashacl \
--ont-graph owl-REPRODUCTION.ttl \
--shacl sh-REPRODUCTION-1.ttl \
kb-REPRODUCTION-2.ttl
check-3: .venv.done.log
source venv/bin/activate \
&& pyshacl \
--metashacl \
--ont-graph owl-REPRODUCTION.ttl \
--shacl sh-REPRODUCTION-2.ttl \
kb-REPRODUCTION-1.ttl
check-4: .venv.done.log
source venv/bin/activate \
&& pyshacl \
--metashacl \
--ont-graph owl-REPRODUCTION.ttl \
--shacl sh-REPRODUCTION-2.ttl \
kb-REPRODUCTION-2.ttl
clean:
@rm -f .venv.done.log
@rm -rf venv
@prefix ex: <http://example.org/ontology/> .
@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 xsd: <http://www.w3.org/2001/XMLSchema#> .
ex:OneXorThing
a owl:Class ;
owl:disjointUnionOf (
ex:ThingA
ex:ThingB
) ;
.
ex:ThingA
a owl:Class ;
rdfs:subClassOf ex:OneXorThing ;
owl:disjointWith ex:ThingB ;
.
ex:ThingB
a owl:Class ;
rdfs:subClassOf ex:OneXorThing ;
owl:disjointWith ex:ThingA ;
.
ex:ThingC
a owl:Class ;
rdfs:subClassOf ex:TwoXorThing ;
owl:disjointWith ex:ThingD ;
.
ex:ThingD
a owl:Class ;
rdfs:subClassOf ex:TwoXorThing ;
owl:disjointWith ex:ThingC ;
.
ex:ThingE
a owl:Class ;
rdfs:subClassOf ex:TwoXorThing ;
owl:disjointWith ex:ThingF ;
.
ex:ThingF
a owl:Class ;
rdfs:subClassOf ex:TwoXorThing ;
owl:disjointWith ex:ThingE ;
.
ex:TwoXorThing
a owl:Class ;
owl:disjointUnionOf
(
ex:ThingC
ex:ThingD
) ,
(
ex:ThingE
ex:ThingF
)
;
.
@prefix ex: <http://example.org/ontology/> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix sh-ex: <http://example.org/shapes/> .
@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 xsd: <http://www.w3.org/2001/XMLSchema#> .
sh-ex:TwoXorThing-shape
a sh:NodeShape ;
sh:targetClass ex:TwoXorThing ;
sh:xone
(
[
a sh:NodeShape ;
sh:class ex:ThingC ;
]
[
a sh:NodeShape ;
sh:class ex:ThingD ;
]
) ,
(
[
a sh:NodeShape ;
sh:class ex:ThingE ;
]
[
a sh:NodeShape ;
sh:class ex:ThingF ;
]
)
;
.
@prefix ex: <http://example.org/ontology/> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix sh-ex: <http://example.org/shapes/> .
@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 xsd: <http://www.w3.org/2001/XMLSchema#> .
sh-ex:OneXorThing-shape
a sh:NodeShape ;
sh:targetClass ex:TwoXorThing ;
sh:xone (
[
a sh:NodeShape ;
sh:class ex:ThingA ;
]
[
a sh:NodeShape ;
sh:class ex:ThingB ;
]
) ;
.
sh-ex:TwoXorThing-shape
a sh:NodeShape ;
sh:targetClass ex:TwoXorThing ;
sh:xone
(
[
a sh:NodeShape ;
sh:class ex:ThingC ;
]
[
a sh:NodeShape ;
sh:class ex:ThingD ;
]
) ,
(
[
a sh:NodeShape ;
sh:class ex:ThingE ;
]
[
a sh:NodeShape ;
sh:class ex:ThingF ;
]
)
;
.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment