lambdamusic / Ontospy

Python library and command-line interface for inspecting and visualizing RDF models aka ontologies.
http://lambdamusic.github.io/Ontospy/
MIT License
219 stars 52 forks source link

Adjust notion of "Top-level property" to account for SHACL shapes #108

Closed balon closed 2 years ago

balon commented 2 years ago

This patch will address use cases where an ontology may define no or few rdfs:domain statements for its properties, instead relating properties to classes via SHACL shapes. If a property is associated to classes via SHACL property shapes within an ontology, it does not seem appropriate to treat the property as universally applicable.

Contained is a new method in the SparqlHelper class, which will find find the properties that should not be "top-level" due to applying to a class as a SHACL PropertyShape, and adjust the "Top-level property" based on this query.

Please advise if there is a better approach to solving this case where an ontology may utilize OWL, SHACL, or both.

ajnelson-nist commented 2 years ago

Apologies for the in-flight update, but review of the SHACL specification showed one of the triples we had thought was explicitly required could be inferred from other conditions. The query now behaves more in line with the SHACL specification.