I am using the following function to get a list of all the equivalent
classes of a given class.

*Inputs* :

   1. myModel: is my jena OntModel.
   2. classURI : URI of the class for which I want to fetch the equivalent
   classes.

*Output* : List<String> containing the URIs of the equivalent classes.
*Function* :

public static List<String> getEquivalentClasses(String classURI, OntModel
myModel){
        List<String> list = new ArrayList<String>();
        OntClass oc = myModel.getOntClass(classURI);

        ExtendedIterator<OntClass> InstIt = oc.listEquivalentClasses();
        while (InstIt.hasNext())
        {
            oc=InstIt.next();
            if(oc.getURI()!=null)
            list.add(oc.getURI());
        }

       return list;
    }



I use the same logic to fetch a list of subclasses of a given class, which
works fine.

But it doesn't works for Equivalent classes.

I have tried this on the Pizza
<http://protege.stanford.edu/ontologies/pizza/pizza.owl> ontology, for
class Pizza and CheesyPizza. It has many equivalent classes when opened in
protege, but unable to list any via the OntClass.listEquivalentClasses()
API of Jena.

To my observation, the for example class CheeseyPizza is an equivalent to
Pizza class and further has some property restriction as "hasTopping some
CheeseTopping" , is this got something to do with it??
-- 
*Dibyanshu Jaiswal*
Mb: +91 9038304989

Reply via email to