我想通过使用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