简体   繁体   中英

Print subclasses of all defined classes without printing the unsatisfied classes

i am new to OWLAPi , i am using Jfact1.2.1 reasoner.

In my ontology there are two unsatisfiable classes . I want to print all the subclasses without these two unsatisfied classes. I've made some codes using array and i was successful however, i didn't like this array thing as i can not use it for other unknown ontologies which might have more than 2 unsatisfiable classes.

So my question is, is there a way to print out all the subclasses of defined classes without having the unsitisfiable classes present in them? i really need someone's help as i've tried everything. If anyone is interested in the array method i've used to the codes are below

OWLClass[] array = new OWLClass[3];
int i=0;

Node<OWLClass> bottomNode = reasoner.getUnsatisfiableClasses();

    Set<OWLClass> unsatisfiable = bottomNode.getEntitiesMinusBottom();


        for (OWLClass cls : unsatisfiable) {


            array[i]= cls;
            i++;
        }
    for (OWLClass c : myOntology.getClassesInSignature()) {
NodeSet<OWLClass> subClasses = reasoner.getSubClasses(c, True);

        for (OWLClass subClass : subClasses.getFlattened()) {
if (subClass.isBottomEntity()|| subClass.equals(array[0])|| 
     subClass.equals(array[1])|| subClass.equals(array[2])){


      continue;

else{
    System.out.println(subClass.getIRI().getFragment() + "\tsubclass of\t" 
   + c.getIRI().getFragment());
 }
}
}

Replace

if (subClass.isBottomEntity()|| subClass.equals(array[0])|| 
 subClass.equals(array[1])|| subClass.equals(array[2])){

with

if (subClass.isBottomEntity()|| unsatisfiable.contains(subclass)) {

which has the same effect. There's no need for you to copy the unsatisfiable set out to an array.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM