Add non-redundant-tree logic for ontodocs #87
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello Michele (a.k.a. @lambdamusic). Please, consider the integration of this PR into Ontospy.
In a nutshell
This PR allows the generation of ontologyClassTrees, ontologyPropTrees, ontologyConceptTrees without repeating redundant sub-entities along the hierarchy. It display a "distinct" taxonomy without repetitions. Multi-inheritance (i.e., a class inheriting from diverse classes) is preserved.
Application
Useful when you need to represent trees of full reasoned ontologies (e.g., when you load the ontology from the SPARQL endpoint of Ontotext's GraphDB with reasoning enabled). In those cases new implicit triples are inferred and added to the knowledge graph (e.g., due to the transitivity of properties like
rdfs:subClassOf
) but you might not want to visualize all implicit sub-*-classes relations in the ontodocs trees.Rationale
Rule introduced:
Full story
Let's start from this ontology
:Mammal
is subclassed by:Human
that is subclassed by:Red-beardedGuy
. If this ontology is reasoned with common rulesets, the following triple is materialized:Now, if we call the legacy version of
ontologyClassTrees
, we would get this tree in the ontology doc:...and it's perfectly fine. Indeed,
:Red-beardedGuy
is a sub-class both of:Mammal
and of:Human
. However, this representation could be pretty redundant for some uses. A kind of "distinct" taxonomy like this one is desirable:and it makes much more sense to the reader. : )
To get this, I introduced the arg
repeatChildren
in the tree methods of the classOntospy
(it defaults toTrue
for backward compatibility). ItrepeatChildren
is set toFalse
, you get the non-redundant tree version.Let me know your reactions as you go through it.
Ciao Michele e grazie per questo bel lavoro che metti a disposizione qui su GitHub!