Consider a Named Individual "Cow". Its Class is also "Cow" and In turn Cow is subclass of Mammal and Mammal is subclass of livingbeing and so on. if i have access to the OWLNamedIndividual as follows:-
for (OWLNamedIndividual i : localUni.getIndividualsInSignature())
{
Code that should give me ...
i = Cow (NamedIndividual)
Class = Cow
One Level up class = Mammal
}
i tried the following but to no avail
System.out.println(i.getEntityType().getName() );
System.out.println(i.getEntityType().toString() );
System.out.println(i.getTypes(myontology) ); // this would give me error NoSuchMethodError
Thanks.
getEntityType()
only returns OWLCLASS/OWLOBJECTPROPERTY/OWLNAMEDIDIVIDUAL, i.e., OWLAPI specific values about what an entity is, not about its role in an ontology or position in a hierarchy.
Also, it is possible to pun (i.e., an OWLNamedIndividual
and an OWLClass
can have the same IRI), but the two entities are distinct, so from one you cannot go to the other directly.
OWLNamedIndividual.getTypes(OWLOntology)
has been removed in version 4.
It is possible to achieve the same result with
EntitySearcher.getTypes(OWLIndividual, OWLOntology)
Note that the results will only be asserted types for the individual - in order to get inferred results, you need to use an OWLReasoner
.
Reasoners are still built the same way as for OWLAPI 3: https://github.com/owlcs/owlapi/wiki/DL-Queries-with-a-real-reasoner
However there are no releases of reasoners using OWLAPI 4, as far as I know. There are a few experimental branches: The version4 branch of JFact is in SNAPSHOT state: https://github.com/owlcs/jfact A HermiT fork working with OWLAPI 4 is available here: https://github.com/ignazio1977/hermit-reasoner Both will need local build to be used.