How to get annotations from owl individual using OWLAPI

依然范特西╮ 提交于 2019-12-11 18:58:51

问题


I already know how to get annotations from OWL classes (see the java code below). But I'm not able to get annotations from OWL individuals. Could anybody please tell me how to code the same functionality for an OWLIndividual instead of an OWLClass? Thankyou!

IRI iri = IRI.create("http://www.example.com/ontology/108024893-n"); //class IRI
OWLClass clazz = manager.getOWLDataFactory().getOWLClass(iri);

for (OWLAnnotation annotation : clazz.getAnnotations(ontology)) 
{
  System.out.println("\nannotation value: "+annotation.getValue());
}

回答1:


I got the solution: I had to convert individual into an OWLEntity:

OWLEntity entity = (OWLEntity)individual;
for (OWLAnnotation annotation : entity.getAnnotations(ontology)) 
{
    System.out.println("\nannotation property->value: "+annotation.getProperty()+" -> "+annotation.getValue());
}



回答2:


A general solution is to use OWLOntology.getAnnotationAssertionAxioms(OWLAnnotationSubject)

It works with entities and anonymous individuals.



来源:https://stackoverflow.com/questions/25622694/how-to-get-annotations-from-owl-individual-using-owlapi

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!