public void getEquivalentClassesForClass(OWLClass owlClass, OWLOntology ont) {
Stack<OWLClassAxiom> axiomStack = new Stack<OWLClassAxiom>();
axiomStack.addAll(ont.getAxioms(owlClass, null));
List<OWLClass> equivList = new ArrayList<OWLClass>();
while(!axiomStack.isEmpty()) {
OWLClassAxiom a = axiomStack.pop();
if (a.isOfType(AxiomType.EQUIVALENT_CLASSES) && a.getClassesInSignature().size() == 3) {
Iterator<OWLClass> iter = a.getClassesInSignature().iterator();
OWLClass equivClass = iter.next();
equivList.add(equivClass);
}
}
}
Now i need all the data properties that are defined on owl class i.e equivClass in my code. Is there any way to get this. I havent found any api on the given owl class.
As far as I know, you cannot directly get the data properties that have a particular class in their domain.
You can call ont.getAxioms(AxiomType.DATA_PROPERTY_DOMAIN);
which will return all of the domain axioms for all data properties in your ontology, which you can then get the domain classes out of by iterating over this set of axioms.
for(OWLDataPropertyDomainAxiom d : set) {
d.getDomain();
}
where the d.getDomain();
call will return the class in the axiom. You can then check if this class matches the one you are searching for.