[英]How to get the annotations of concepts (annotations on class IRIs) with OWLAPI?
在http://www.obofoundry.org/網站上的pato.owl本體中,某些概念具有多個注釋。 例如,概念PATO_0001051的標簽為“銳角到”和定義為:“小於90度的角度”。 如何通過owlapi定義? 非常感謝。
<owl:Class rdf:about="http://purl.obolibrary.org/obo/PATO_0001051">
<rdfs:label rdf:datatype="http://www.w3.org/2001/XMLSchema#string">acute angle to</rdfs:label>
<rdfs:subClassOf rdf:resource="http://purl.obolibrary.org/obo/PATO_0002326"/>
<obo:IAO_0000115 rdf:datatype="http://www.w3.org/2001/XMLSchema#string">An angle which is less than 90 degrees.</obo:IAO_0000115>
<oboInOwl:id rdf:datatype="http://www.w3.org/2001/XMLSchema#string">PATO:0001051</oboInOwl:id>
<oboInOwl:hasOBONamespace rdf:datatype="http://www.w3.org/2001/XMLSchema#string">quality</oboInOwl:hasOBONamespace>
<oboInOwl:inSubset rdf:resource="http://purl.obolibrary.org/obo/pato#relational_slim"/>
<oboInOwl:inSubset rdf:resource="http://purl.obolibrary.org/obo/pato#value_slim"/>
</owl:Class>
一種解決方法是找到您要查找的類,然后提取與該特定類相關的所有注釋。 請記住,OWLAPI寫得很好,您可以提取大多數IRI的字符串形式。 這是我寫的方式:
for(OWLClass owl_class : localOntology.getClassesInSignature(true)){
if(owl_class.getIRI().getFragment().equalsIgnoreCase("PATO_0001051"))
for(OWLAnnotationAssertionAxiom annotations:owl_class.getAnnotationAssertionAxioms(localOntology))
System.out.println(annotations.getProperty().getIRI().getFragment()+ " "+ annotations.getValue());
}
結果如下:
尊敬的Artemis和Ignazio,非常感謝您的回答。 答案是:
for(OWLClass owl_class : localOntology.getClassesInSignature(true)){
for(OWLAnnotationAssertionAxiom annotations:owl_class.getAnnotationAssertionAxioms(localOntology))
if(annotations.getProperty().getIRI().getFragment()==null) {
System.out.println("definition: "+annotations.getValue());
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.