如何从OWL Ontology标头值中检索值

时间:2015-10-07 09:51:03

标签: owl ontology

有人可以帮助我们使用JenaOWLModel或OWLOntology从以下示例OWL标头中获取标头值。

<owl:Ontology rdf:about="">
  <owl:versionInfo>v 1.17 2003/02/26 12:56:51 mdean</owl:versionInfo>
  <rdfs:comment>An example ontology</rdfs:comment>
  <owl:imports rdf:resource="http://www.example.org/foo"/>
</owl:Ontology>

You can refer http://www.w3.org/TR/owl-ref/#Annotations (2.2. Ontology Headers) for more reference.

I tried using the below code to fetch the values, but not able to fetch the values. I can just see the keys. Any help would be appreciated.



        OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
    OWLDataFactory dataFactory = manager.getOWLDataFactory();
    OWLOntology owlLOntology = manager.loadOntologyFromOntologyDocument(new File(dataPath));
    Set owlAnnotationPropertySet = owlLOntology.getAnnotationPropertiesInSignature();
    Iterator<OWLAnnotationProperty> iter = owlAnnotationPropertySet.iterator();while(iter.hasNext()){   
        OWLAnnotationProperty owlAnnotationProperty = (OWLAnnotationProperty) iter.next();    
    }

由于 阿努拉格

1 个答案:

答案 0 :(得分:1)

如果您使用的是OWL API,可以使用

获取本体IRI(rdf:about标签的内容)和版本信息
owlLOntology.getOntologyID().getOntologyIRI(); 

owlLOntology.getOntologyID().getVersionInfo();

对于注释,您可以尝试

for (OWLAnnotation annontation: o.getAnnotations() {
 annotation.getValue();
}

获取每个注释属性的值。至于进口,请尝试owlLOntology.getImports();