我想通過使用OWL API解析OWL2文件。但是當我試圖解析標籤<SubClassOf></SubClassOf>
時,我遇到了問題。請看下面的例子。解析內容是相反的順序
<?xml version="1.0"?>
<Ontology xmlns="http://www.w3.org/2006/12/owl2-xml#"
......>
<SubClassOf>
<Class URI="&ontology_people1;Address"/>
<Class URI="&ontology_people1;Location"/>
</SubClassOf>
......
</Ontology>
<SubClassOf> and </SubClassOf>
之間的內容被寫入順序。 子類被寫在第一行,父類被寫在第二行。但我解析它並在控制檯中打印。他們的順序是相反的。與此同時,其他人並不相反。我的代碼在下面。
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
File file = new File("src/main/resources/dataSet/PR/person1/ontology_people1.owl");
OWLOntology o = manager.loadOntologyFromOntologyDocument(file);
List<OWLAxiom> subClassOf = o.axioms()
.filter(axiom -> axiom.getAxiomType().toString().equals("SubClassOf"))
.collect(Collectors.toList());
for (OWLAxiom owlAxiom : subClassOf) {
Stream<OWLEntity> owlEntityStream = owlAxiom.signature();
owlEntityStream.forEach(entity->System.out.println(entity.getIRI()));
System.out.println("**************");
}
爲什麼?
@Ignazio對不起,你幫了我很多次,我知道你是OWL API的作者,你可以幫我再次?謝謝 ! – ciferlv