Open floatingpurr opened 4 years ago
Hello Andrea this looks very useful. I will review a bit more before merging. PS Massive apologies for the abysmal delay in getting back to you!
Hey Michele, no worries at all. This is just a little contribution. I really enjoyed working with this library!
Any progress in getting this nice looking PR accepted?
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!