如何使用 OWLAPI 获取概念的注释(class IRI 上的注释)?

How to get the annotations of concepts (annotations on class IRIs) with OWLAPI?

在pato.owlontology网站http://www.obofoundry.org/中,有些概念有多个Annotation。例如,概念 PATO_0001051 具有标签 "acute angle to" 和定义:"An angle which is less than 90 degrees"。我怎样才能通过owlapi得到这个Definition?非常感谢。

    <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>

解决此问题的一种方法是找到您正在寻找的 class,然后提取与该特定 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());
                                                                        }
                                                         }