[英]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.