简体   繁体   English

使用JENA API-从OWL文件中获取所有类

[英]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? 是否可以使用JENA获取OWL文件中存在的所有类的名称并存储在数组列表中?

   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 . 是的,请参阅Javadoc for OntModel.listClasses You can easily copy the contents of the Iterator into an array or List . 您可以轻松地将Iterator的内容复制到数组或List That you're asking the question suggests that you'll probably benefit from reading the Jena ontology API documentation 您所提出的问题表明您可能会从阅读Jena本体API文档中受益

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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