简体   繁体   中英

Using JENA API - Getting all the classes from OWL file

Is it possible to get name of all the classes present in OWL file using JENA and store in the Array List?

   OntModel base = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM, null);
    OntModel model = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM_MICRO_RULE_INF, null);

    String NS = "http://www.abc.com/abcportal/abc.owl" + "#";

base.read("file:abcInstance.owl");
    ExtendedIterator<OntClass> iter = base.listClasses();

    while ( iter.hasNext()){
        System.out.println(iter.next());
    }

Yes it is, see the Javadoc for OntModel.listClasses . You can easily copy the contents of the Iterator into an array or List . That you're asking the question suggests that you'll probably benefit from reading the Jena ontology API documentation

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