I'm having a quick question regarding the usage of the owl api.
Say I have a class called Species, which has a Subclass mammal, which has a Subclass Primate, which has a subclass Human.
species -> mammal -> primate -> human
For some reason, I would like to reclassify this in our software and say that Primates are not longer considered Mammals, instead they should be a direct subclass of a Species.
Meaning our graph should look like this now
species -> primate -> human
can anybody please point me in the right direction?
Finding our the parent class is easy enough, using the owl-api
reasoner.getSuperClasses(chield, true).entities().collect(Collectors.toSet[OWLClass])
but how can I 'detach' my class now from it's parent?
If you have an ontology where the relations :
- species -> mammal
- mammal -> primate
- primate -> human
are directly asserted (not the result of a reasoning computation).
Then in owlapi this is represented as axioms :
- OWLSubClass(mammal, species)
- OWLSubClass(primate, mammal)
- OWLSubClass(human, primate)
The solution could be to remove the old subClass assertion and add the new one (unless you are playing with Allen-temporal).
OWLDataFactory factory = manager.getOWLDataFactory();
ontology.remove(factory.getOWLSubClassOfAxiom(primate, mammal));
ontology.add(factory.getOWLSubClassOfAxiom(primate, species));
Note : if you are using a version older than 5 of owlapi then we must use the OWLOntologyManager to remove/add axioms in an ontology :
manager.remove(ontology, axiom)
manager.add(ontology, axiom)
If the specialization relation aren't directly asserted in your ontology; it will be far more complex. You have to know why 'human' is view a subclass of 'mammal'. Maybe the 'explanation' system of the 'reasoner' can help you.