30 September 2017 3 9K Report

I need to get All direct superclasses of one class from the ontology, and I need just named classes, not those gotten from the equivalent expression with 'AllValuesFrom' restriction. I tried with the code below, it works for some ontologies that I create but others downloaded from the web (people ontology - pizza ontology) it doesn't work.

public void motherclasses_Of_One_class() {

for (OWLClass clss : ontology.getClassesInSignature())

{

if(reasoner.getSuperClasses(clss, true).getFlattened().size()>1) // if the class has more than one mother class

{// System.out.println(" \n ---------------- : \n");

System.out.println("\n class "+clss.getIRI().getFragment()+" has more than one mother classes : \n");

for(OWLClass parent: reasoner.getSuperClasses(clss, true).getFlattened())

System.out.println(parent.getIRI().getFragment());

            }

       }

  }

I tried with this version of code too, the same result as the first version :

NodeSet superclasses = reasoner.getSuperClasses(clss, true);

for (org.semanticweb.owlapi.reasoner.Node parentOWLNode: superclasses) {

OWLClassExpression parent = parentOWLNode.getRepresentativeElement();

System.out.println(parent.getClassesInSignature());.out.println(parent.getClassesInSignature());

}

the problem with downloaded ontologies, that it returns wrong superclasses for a class. I check the . OWL file, then the ontology through protégé, I can't find from when the problem comes. Please find below a wrong case to understand more what I mean.

In the example, 'cat_owner' class has just one mother 'person' class. As you can see, pet_owner and cat_liker classes are at the same hierarchical level as 'cat_owner' class, they can never be mothers for 'cat_owner' class, and more than that in the description of 'cat_owner' class there is just one superclass 'person' class... but in the program output I get them as superclass 'person' class... but in the program output I get them as superclasses of 'cat_owner' class when 'person' class is absent form the list. I can't understand why... this is the output: from the list. I can't understand why...

Please if you have any idea that may help, I would be grateful. Thank you

More Hasna Abioui's questions See All
Similar questions and discussions