2015-10-07 39 views
0

有人可以幫助如何使用JenaOWLModel或OWLOntology從下面的示例OWL頭中獲取頭值。如何從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

如果您正在使用OWL API,你可以得到本體IRI(在RDF的內容:有關標籤)通過使用

owlLOntology.getOntologyID().getOntologyIRI(); 

和版本信息
owlLOntology.getOntologyID().getVersionInfo(); 

對於註釋你可以試試

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

獲取每個註釋屬性的值。至於進口嘗試
owlLOntology.getImports();

+0

任何想法如何得到下面 創作者的價值創作者名稱 – Anurag

+0

'創建者名稱'將成爲您的本體的註釋。因此,遍歷每個註釋應該會返回該註釋。有關如何實現此目的的某些代碼,請參閱編輯答案。 –