[Pellet-users] listEquivalentClasses()

Anitha anithacse at yahoo.com
Thu Mar 6 04:16:20 UTC 2008


 HI Pellet Users,
    I am using jena api and  edu.stanford.smi.protegex.owl.model.OWLModel to extract the equivalent clasess from owl file

My program:
import java.io.*;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Iterator;
import java.util.Map;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;
import com.hp.hpl.jena.ontology.*;
import com.hp.hpl.jena.rdf.model.*;
import com.hp.hpl.jena.util.iterator.ExtendedIterator;
import edu.stanford.smi.protegex.owl.model.OWLModel;
public class test {
 public static void main(String[] args) throws IOException,
   InterruptedException {
       OntModel m = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
       String fname = "http://www.berkeleybop.org/ontologies/owl/bfo.owl";
        m.read(fname);
   for(Iterator i=m.listClasses();i.hasNext()){        
    OntClass prop = i.next();
       List<String> eqiclasses = new ArrayList<String>();
       Iterator j1 = prop.listEquivalentClasses();
          while( j1.hasNext() ) {
                OntClass equivClass = (OntClass) j1.next();
                eqiclasses.add(equivClass.getLocalName());
          }
        System.out.println("Class"+ prop.getLocalName() + " EQ:" + eqiclasses  + "from prop" + prop.listEquivalentClasses().toList());
   }
  
}


The output of this program.  returns the  following
Class:ConnectedSpatiotemporalRegion EQ:[null] from prop [-391a75f9:1188239ebcb:-7fe3]

I mean the classes Connected Spatio.. return some equivalent class list but when I try through the iterator it returns null. please help me to get all equivalent clasess

regards
anitha


      ____________________________________________________________________________________
Looking for last minute shopping deals?  
Find them fast with Yahoo! Search.  http://tools.search.yahoo.com/newsearch/category.php?category=shopping


More information about the Pellet-users mailing list