简体   繁体   English

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

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

In the pato.owl ontology on the website http://www.obofoundry.org/ , some concepts has more than one Annotation. http://www.obofoundry.org/网站上的pato.owl本体中,某些概念具有多个注释。 For example, concept PATO_0001051 has Label "acute angle to" and the definition: "An angle which is less than 90 degrees". 例如,概念PATO_0001051的标签为“锐角到”和定义为:“小于90度的角度”。 How can I get through owlapi this Definition? 如何通过owlapi定义? Many thanks. 非常感谢。

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

One way to approach this, is to find the class that you are looking for and then extract all the annotations that relate to that specific class. 一种解决方法是找到您要查找的类,然后提取与该特定类相关的所有注释。 Remember that OWLAPI is quite well written and you can extract the string form of most of the IRIs. 请记住,OWLAPI写得很好,您可以提取大多数IRI的字符串形式。 This is the way I have written it: 这是我写的方式:

        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());
    }

The result looks like: 结果如下:

在此处输入图片说明

Dear Artemis and Ignazio, thank you very much for your answers. 尊敬的Artemis和Ignazio,非常感谢您的回答。 Here is the answer: 答案是:

    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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM