Skip to content
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

Hygiene tests update (WIP) #2026

Draft
wants to merge 10 commits into
base: master
Choose a base branch
from
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix owl: <http://www.w3.org/2002/07/owl#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>

##
# banner Property subPropertyOf hierarchy shouldn't be circular.

SELECT DISTINCT ?error ?property
WHERE
{
FILTER regex(str(?property), <HYGIENE_TESTS_FILTER_PARAMETER>)
?property rdfs:subPropertyOf+ ?property .
FILTER NOT EXISTS {?property owl:deprecated "true"^^xsd:boolean} .

BIND (concat ("PRODERROR: There is a hierarchy cycle around property ", str(?property)) AS ?error)
}
12 changes: 12 additions & 0 deletions etc/testing/hygiene_parameterized/testHygiene_long_IRIs.sparql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
##
# banner No IRI should be longer than 255 chars.


SELECT DISTINCT ?error ?resource
WHERE
{
?resource ?property ?value .
FILTER (STRLEN(STR(?resource)) > 255)
FILTER regex(str(?resource), <HYGIENE_TESTS_FILTER_PARAMETER>)
BIND (concat("WARN: IRI ", STR(?resource), " is longer than 255 chars.") AS ?error)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix owl: <http://www.w3.org/2002/07/owl#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix afn: <http://jena.apache.org/ARQ/function#>

##
# banner We should avoid restrictions that can be inferred from other restrictions. Here we check exact and min cardinality restrictions.

SELECT ?error ?class
WHERE
{
?class rdfs:subClassOf ?restriction1.
?class rdfs:subClassOf ?restriction2.
?restriction1 rdf:type owl:Restriction.
?restriction2 rdf:type owl:Restriction.
?restriction1 owl:onProperty ?property1.
?restriction2 owl:onProperty ?property2.
?restriction1 owl:onClass ?restrictingClass1.
?restriction2 owl:onClass ?restrictingClass2.
?restriction1 owl:qualifiedCardinality ?cardinality1.
?restriction2 owl:minQualifiedCardinality ?cardinality2.
{?property1 rdfs:subPropertyOf+ ?property2.} UNION {FILTER (?property1 = ?property2)}
?restrictingClass1 rdfs:subClassOf* ?restrictingClass2.
FILTER (?cardinality1 >= ?cardinality2)
FILTER regex(str(?class), <HYGIENE_TESTS_FILTER_PARAMETER>)
BIND (CONCAT(STR(afn:localname(?property1)), " exactly ", STR(?cardinality1), " ", STR(afn:localname(?restrictingClass1))) as ?restriction1String)
BIND (CONCAT(STR(afn:localname(?property2)), " min ", STR(?cardinality2), " ", STR(afn:localname(?restrictingClass2))) as ?restriction2String)
BIND(CONCAT("PRODERROR: Class ", STR(?class), " has obsolete min cardinality restriction <", ?restriction2String, "> because of exact cardinality restriction <", ?restriction1String, ">.") as ?error)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix owl: <http://www.w3.org/2002/07/owl#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix afn: <http://jena.apache.org/ARQ/function#>

##
# banner We may want to avoid restrictions that can be remotely inferred from other restrictions. Here we check remote exact and min cardinality restrictions.

SELECT ?error ?class
WHERE
{
?class rdfs:subClassOf+ ?restriction1.
?superClass rdfs:subClassOf ?restriction1.
?class rdfs:subClassOf ?restriction2.
?restriction1 rdf:type owl:Restriction.
?restriction2 rdf:type owl:Restriction.
?restriction1 owl:onProperty ?property1.
?restriction2 owl:onProperty ?property2.
?restriction1 owl:onClass ?restrictingClass1.
?restriction2 owl:onClass ?restrictingClass2.
?restriction1 owl:qualifiedCardinality ?cardinality1.
?restriction2 owl:minQualifiedCardinality ?cardinality2.
{?property1 rdfs:subPropertyOf+ ?property2.} UNION {FILTER (?property1 = ?property2)}
?restrictingClass1 rdfs:subClassOf* ?restrictingClass2.
FILTER (?cardinality1 >= ?cardinality2)
FILTER (?cardinality1 > 0)
FILTER regex(str(?class), <HYGIENE_TESTS_FILTER_PARAMETER>)
BIND (CONCAT(STR(afn:localname(?property1)), " exactly ", STR(?cardinality1), " ", STR(afn:localname(?restrictingClass1))) as ?restriction1String)
BIND (CONCAT(STR(afn:localname(?property2)), " min ", STR(?cardinality2), " ", STR(afn:localname(?restrictingClass2))) as ?restriction2String)
BIND (CONCAT("WARN: Class ", STR(?class), " may inherit obsolete min cardinality restriction <", ?restriction2String, "> because of exact cardinality restriction <", ?restriction1String, ">", " from class ", STR(?restrictingClass1)) as ?error)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix owl: <http://www.w3.org/2002/07/owl#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix afn: <http://jena.apache.org/ARQ/function#>

##
# banner We may want to avoid restrictions that can be inferred from other restrictions. Here we check exact and max cardinality restrictions.


SELECT ?error ?class
WHERE
{
?class rdfs:subClassOf ?restriction1.
?class rdfs:subClassOf ?restriction2.
?restriction1 rdf:type owl:Restriction.
?restriction2 rdf:type owl:Restriction.
?restriction1 owl:onProperty ?property1.
?restriction2 owl:onProperty ?property2.
?restriction1 owl:onClass ?restrictingClass1.
?restriction2 owl:onClass ?restrictingClass2.
?restriction1 owl:maxQualifiedCardinality ?cardinality1.
?restriction2 owl:qualifiedCardinality ?cardinality2.
{?property1 rdfs:subPropertyOf+ ?property2.} UNION {FILTER (?property1 = ?property2)}
?restrictingClass1 rdfs:subClassOf* ?restrictingClass2.
FILTER (?restriction1 != ?restriction2)
FILTER (?cardinality1 >= ?cardinality2)
FILTER (?cardinality1 > 0)
FILTER regex(str(?class), <HYGIENE_TESTS_FILTER_PARAMETER>)
BIND (CONCAT(STR(afn:localname(?property1)), " max ", STR(?cardinality1), " ", STR(afn:localname(?restrictingClass1))) as ?restriction1String)
BIND (CONCAT(STR(afn:localname(?property2)), " exactly ", STR(?cardinality2), " ", STR(afn:localname(?restrictingClass2))) as ?restriction2String)
BIND(CONCAT("WARN: Class ", STR(?class), " may inherit obsolete max cardinality restriction <", ?restriction1String, "> because of exact cardinality restriction <", ?restriction2String, ">.") as ?error)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix owl: <http://www.w3.org/2002/07/owl#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix afn: <http://jena.apache.org/ARQ/function#>

##
# banner We may want to avoid restrictions that can be remotely inferred from other restrictions. Here we check remote exact and max cardinality restrictions.


SELECT ?error ?class
WHERE
{
?class rdfs:subClassOf+ ?restriction2.
?superClass rdfs:subClassOf ?restriction2.
?class rdfs:subClassOf ?restriction1.
?restriction1 rdf:type owl:Restriction.
?restriction2 rdf:type owl:Restriction.
?restriction1 owl:onProperty ?property1.
?restriction2 owl:onProperty ?property2.
?restriction1 owl:onClass ?restrictingClass1.
?restriction2 owl:onClass ?restrictingClass2.
?restriction1 owl:maxQualifiedCardinality ?cardinality1.
?restriction2 owl:qualifiedCardinality ?cardinality2.
{?property1 rdfs:subPropertyOf+ ?property2.} UNION {FILTER (?property1 = ?property2)}
?restrictingClass1 rdfs:subClassOf* ?restrictingClass2.
FILTER (?cardinality1 >= ?cardinality2)
FILTER (?cardinality1 > 0)
FILTER regex(str(?class), <HYGIENE_TESTS_FILTER_PARAMETER>)
BIND (CONCAT(STR(afn:localname(?property1)), " max ", STR(?cardinality1), " ", STR(afn:localname(?restrictingClass1))) as ?restriction1String)
BIND (CONCAT(STR(afn:localname(?property2)), " exactly ", STR(?cardinality2), " ", STR(afn:localname(?restrictingClass2))) as ?restriction2String)
BIND(CONCAT("WARN: Class ", STR(?class), " may inherit obsolete max cardinality restriction <", ?restriction1String, "> because of exact cardinality restriction <", ?restriction2String, ">", " from class ", STR(?superClass)) as ?error)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix owl: <http://www.w3.org/2002/07/owl#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix afn: <http://jena.apache.org/ARQ/function#>

##
# banner We should avoid restrictions that can be inferred from other restrictions. Here we check max cardinality restrictions.


SELECT ?error ?class
WHERE
{
?class rdfs:subClassOf ?restriction1.
?class rdfs:subClassOf ?restriction2.
?restriction1 rdf:type owl:Restriction.
?restriction2 rdf:type owl:Restriction.
?restriction1 owl:onProperty ?property1.
?restriction2 owl:onProperty ?property2.
?restriction1 owl:onClass ?restrictingClass1.
?restriction2 owl:onClass ?restrictingClass2.
?restriction1 owl:maxQualifiedCardinality ?cardinality1.
?restriction2 owl:maxQualifiedCardinality ?cardinality2.
{?property1 rdfs:subPropertyOf+ ?property2.} UNION {FILTER (?property1 = ?property2)}
?restrictingClass1 rdfs:subClassOf* ?restrictingClass2.
FILTER (?restriction1 != ?restriction2)
FILTER (?cardinality1 >= ?cardinality2)
FILTER (?cardinality2 > 0)
FILTER regex(str(?class), <HYGIENE_TESTS_FILTER_PARAMETER>)
BIND (CONCAT(STR(afn:localname(?property1)), " max ", STR(?cardinality1), " ", STR(afn:localname(?restrictingClass1))) as ?restriction1String)
BIND (CONCAT(STR(afn:localname(?property2)), " max ", STR(?cardinality2), " ", STR(afn:localname(?restrictingClass2))) as ?restriction2String)
BIND(CONCAT("PRODERROR: Class ", STR(?class), " has obsolete max cardinality restriction <", ?restriction1String, "> because of max cardinality restriction <", ?restriction2String, ">.") as ?error)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix owl: <http://www.w3.org/2002/07/owl#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix afn: <http://jena.apache.org/ARQ/function#>

##
# banner We may want to avoid restrictions that can be remotely inferred from other restrictions. Here we check remote exact and max cardinality restrictions.


SELECT ?error ?class
WHERE
{
?class rdfs:subClassOf+ ?restriction2.
?superClass rdfs:subClassOf ?restriction2.
?class rdfs:subClassOf ?restriction1.
?restriction1 rdf:type owl:Restriction.
?restriction2 rdf:type owl:Restriction.
?restriction1 owl:onProperty ?property1.
?restriction2 owl:onProperty ?property2.
?restriction1 owl:onClass ?restrictingClass1.
?restriction2 owl:onClass ?restrictingClass2.
?restriction1 owl:maxQualifiedCardinality ?cardinality1.
?restriction2 owl:maxQualifiedCardinality ?cardinality2.
{?property1 rdfs:subPropertyOf+ ?property2.} UNION {FILTER (?property1 = ?property2)}
?restrictingClass1 rdfs:subClassOf* ?restrictingClass2.
FILTER (?restriction1 != ?restriction2)
FILTER (?cardinality1 >= ?cardinality2)
FILTER (?cardinality2 > 0)
FILTER regex(str(?class), <HYGIENE_TESTS_FILTER_PARAMETER>)
BIND (CONCAT(STR(afn:localname(?property1)), " max ", STR(?cardinality1), " ", STR(afn:localname(?restrictingClass1))) as ?restriction1String)
BIND (CONCAT(STR(afn:localname(?property2)), " max ", STR(?cardinality2), " ", STR(afn:localname(?restrictingClass2))) as ?restriction2String)
BIND(CONCAT("WARN: Class ", STR(?class), " may inherit obsolete max cardinality restriction <", ?restriction1String, "> because of max cardinality restriction <", ?restriction2String, ">", " from class ", STR(?superClass)) as ?error)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix afn: <http://jena.apache.org/ARQ/function#>

##
# banner We should avoid restrictions that can be inferred from other restrictions.
# banner We should avoid restrictions that can be inferred from other restrictions. Here we check min cardinality restrictions.


SELECT ?error
WHERE
Expand All @@ -20,12 +21,13 @@ WHERE
?restriction2 owl:onClass ?restrictingClass2.
?restriction1 owl:minQualifiedCardinality ?minCardinality1.
?restriction2 owl:minQualifiedCardinality ?minCardinality2.
{?property1 rdfs:subPropertyOf+ ?property2.} UNION {?property1 rdfs:subPropertyOf* ?property2. FILTER (?property1 = ?property2)}
{?property1 rdfs:subPropertyOf+ ?property2.} UNION {FILTER (?property1 = ?property2)}
{?restrictingClass1 rdfs:subClassOf+ ?restrictingClass2.} UNION {?restrictingClass1 rdfs:subClassOf* ?restrictingClass2. FILTER (?restrictingClass1 = ?restrictingClass2)}
FILTER (?restriction1 != ?restriction2)
FILTER (?minCardinality1 >= ?minCardinality2)
FILTER (?minCardinality1 != 0)
FILTER regex(str(?class), <HYGIENE_TESTS_FILTER_PARAMETER>)
BIND (CONCAT(STR(afn:localname(?property1)), " min ", STR(?minCardinality1), " ", STR(afn:localname(?restrictingClass1))) as ?restriction1String)
BIND (CONCAT(STR(afn:localname(?property2)), " min ", STR(?minCardinality2), " ", STR(afn:localname(?restrictingClass2))) as ?restriction2String)
BIND(CONCAT("WARN: Class ", STR(?class), " has obsolete restriction <", ?restriction2String, "> because of restriction <", ?restriction1String, ">.") as ?error)
BIND(CONCAT("PRODERROR: Class ", STR(?class), " has obsolete min cardinality restriction <", ?restriction2String, "> because of min cardinality restriction <", ?restriction1String, ">.") as ?error)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix owl: <http://www.w3.org/2002/07/owl#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix afn: <http://jena.apache.org/ARQ/function#>

##
# banner We should avoid restrictions that can be inferred from other restrictions. Here we check someValues and exact cardinality restrictions.

SELECT ?error ?class
WHERE
{
?class rdfs:subClassOf ?restriction1.
?class rdfs:subClassOf ?restriction2.
?restriction1 rdf:type owl:Restriction.
?restriction2 rdf:type owl:Restriction.
?restriction1 owl:onProperty ?property1.
?restriction2 owl:onProperty ?property2.
?restriction2 owl:onClass ?restrictingClass2.
?restriction2 owl:someValuesFrom ?restrictingClass2.
?restriction1 owl:qualifiedCardinality ?cardinality1.
{?property1 rdfs:subPropertyOf+ ?property2.} UNION {FILTER (?property1 = ?property2)}
?restrictingClass1 rdfs:subClassOf* ?restrictingClass2.
FILTER (?cardinality1 > 0)
FILTER regex(str(?class), <HYGIENE_TESTS_FILTER_PARAMETER>)
BIND (CONCAT(STR(afn:localname(?property1)), " someValuesFrom ", STR(afn:localname(?restrictingClass1))) as ?restriction1String)
BIND (CONCAT(STR(afn:localname(?property2)), " exact ", STR(?cardinality2), " ", STR(afn:localname(?restrictingClass2))) as ?restriction2String)
BIND(CONCAT("PRODERROR: Class ", STR(?class), " has obsolete someValues restriction <", ?restriction2String, "> because of exact cardinality restriction <", ?restriction1String, ">.") as ?error)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix owl: <http://www.w3.org/2002/07/owl#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix afn: <http://jena.apache.org/ARQ/function#>

##
# banner We may want to avoid restrictions that can be remotely inferred from other restrictions. Here we check remote someValues and exact cardinality restrictions.

SELECT ?error ?class
WHERE
{
?class rdfs:subClassOf+ ?restriction1.
?superClass rdfs:subClassOf ?restriction2.
?class rdfs:subClassOf ?restriction2.
?restriction1 rdf:type owl:Restriction.
?restriction2 rdf:type owl:Restriction.
?restriction1 owl:onProperty ?property1.
?restriction2 owl:onProperty ?property2.
?restriction2 owl:onClass ?restrictingClass2.
?restriction2 owl:someValuesFrom ?restrictingClass2.
?restriction1 owl:qualifiedCardinality ?cardinality1.
{?property1 rdfs:subPropertyOf+ ?property2.} UNION {FILTER (?property1 = ?property2)}
?restrictingClass1 rdfs:subClassOf* ?restrictingClass2.
FILTER (?cardinality1 > 0)
FILTER regex(str(?class), <HYGIENE_TESTS_FILTER_PARAMETER>)
BIND (CONCAT(STR(afn:localname(?property1)), " someValuesFrom ", STR(afn:localname(?restrictingClass1))) as ?restriction1String)
BIND (CONCAT(STR(afn:localname(?property2)), " exact ", STR(?cardinality2), " ", STR(afn:localname(?restrictingClass2))) as ?restriction2String)
BIND(CONCAT("WARN: Class ", STR(?class), " may inherit obsolete someValues restriction <", ?restriction1String, "> because of exact cardinality restriction <", ?restriction2String, ">", " from class ", STR(?superClass)) as ?error)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix owl: <http://www.w3.org/2002/07/owl#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix afn: <http://jena.apache.org/ARQ/function#>

##
# banner We should avoid restrictions that can be inferred from other restrictions. Here we check someValues and min cardinality restrictions.

SELECT ?error ?class
WHERE
{
?class rdfs:subClassOf ?restriction1.
?class rdfs:subClassOf ?restriction2.
?restriction1 rdf:type owl:Restriction.
?restriction2 rdf:type owl:Restriction.
?restriction1 owl:onProperty ?property1.
?restriction2 owl:onProperty ?property2.
?restriction1 owl:onClass ?restrictingClass1.
?restriction2 owl:someValuesFrom ?restrictingClass2.
?restriction1 owl:minQualifiedCardinality ?cardinality1.
{?property1 rdfs:subPropertyOf+ ?property2.} UNION {FILTER (?property1 = ?property2)}
?restrictingClass1 rdfs:subClassOf* ?restrictingClass2.
FILTER (?cardinality1 > 0)
FILTER regex(str(?class), <HYGIENE_TESTS_FILTER_PARAMETER>)
BIND (CONCAT(STR(afn:localname(?property1)), " min ", STR(?cardinality1), " ", STR(afn:localname(?restrictingClass1))) as ?restriction1String)
BIND (CONCAT(STR(afn:localname(?property2)), " someValuesFrom ", STR(afn:localname(?restrictingClass2))) as ?restriction2String)
BIND (CONCAT("PRODERROR: Class ", STR(?class), " has obsolete someValues restriction <", ?restriction2String, "> because of min cardinality restriction <", ?restriction1String, ">.") as ?error)
}
Loading