Implemented Hygiene tests:
No Untyped references
Any reference to a URI in any context other than as the object of an annotation property must have a type triple for that URI. https://github.com/edmcouncil/fibo/blob/master/etc/testing/hygiene/testHygiene1.sq
Crossing domains / ranges
If one property is a sub of another, then the domains (respectively ranges) should not be subClasses in the opposite direction. https://github.com/edmcouncil/fibo/blob/master/etc/testing/hygiene/testHygiene2.sq
https://github.com/edmcouncil/fibo/blob/master/etc/testing/hygiene/testHygiene3.sq
Labels and Definitions
Every Class and Property defined in FIBO must have an rdfs:label and a skos:definition https://github.com/edmcouncil/fibo/blob/master/etc/testing/hygiene/testHygiene4.sq
Ontology Metadata
Every Ontology defined in FIBO must have a rdfs:label, sm:copyright, dct:license, dct:abstract https://github.com/edmcouncil/fibo/blob/master/etc/testing/hygiene/testHygiene5.sq
Proposed Hygiene tests:
Definition Format
The definition is made up of one or more full sentences, beginning with an upper case letter and ending with a period.
NO, NO, NO - see https://wiki.edmcouncil.org/display/FLT/Policy+for+Naming+Conventions - definitions should be partial sentences, no capitals, no period at the end - something that can be reused in the place of the concept in a sentence; the format proposed is at the opposite end of the spectrum from this. We have said that we would conform to the recommendations of ISO 704, which is what's specified on the naming conventions page.
No property may have more than one inverse
SPARQL:
SELECT ?p1 ?p2 ?p
WHERE { ?p1 owl:inverseOf ?p.
?p2 owl:inverseOf ?p.
FILTER (?p1 != ?p2) }
Annotations Conventions
Do not use rdfs:Comment for anything. Here is a SPARQL query to catch them. I found two, so this is no big deal.
SELECT ?Resource ?Type ?Comment
WHERE { ?Resource rdf:type ?Type .
?Resource rdfs:comment ?Comment.
FILTER(?Type in (owl:Class, owl:DatatypeProperty,owl:ObjectProperty ))
FILTER(!(STRSTARTS(STR(?Resource), # ignore things in owl namespace
"http://www.w3.org/2002/07/owl#") ))
FILTER(!(STRSTARTS(STR(?Resource), # ignore things in skos namespace
"http://www.w3.org/2004/02/skos/core#") ))
}
ORDER BY ?Type ?Resource
No Unused Imports
Do not import an ontology unless something in it is explicitly referenced.
Here is some pseudo-SPARQL which assumes we've used the nQuads - not sure of the graph selection syntax
SELECT ?Importer ?UnusedImported
WHERE (?Importer a owl:Ontology.
?Importer owl:imports ?UnusedImported.
?ImportedElement rdfs:isDefinedBy ?UnusedImported.
FILTER NOT EXISTS {
GRAPH ?g {?Importer a owl:Ontology # select the named graph containing the triple defining the ontology
?x ?p ?ImportedElement. # check to see if an imported element is the object of a triple in this graph
}
}}
No Unsatisfied References
Any resource referenced should be explicitly declared.
Here is some SPARQL which should be run without inferencing.
SELECT ?source ?property ?ref
WHERE {?property a owl:ObjectProperty.
?source ?property ?ref.
FILTER NOT EXISTS{?ref rdf:type ?t}
}