0

我已经知道如何从 OWL 类中获取注释(参见下面的 java 代码)。但我无法从 OWL 个人那里获得注释。谁能告诉我如何为 OWLIndividual 而不是 OWLClass 编写相同的功能?谢谢!

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

2 回答 2

1

一个通用的解决方案是使用OWLOntology.getAnnotationAssertionAxioms(OWLAnnotationSubject)

它适用于实体和匿名个人。

于 2014-09-02T17:31:22.050 回答
1

我得到了解决方案:我必须将个人转换为 OWLEntity:

OWLEntity entity = (OWLEntity)individual;
for (OWLAnnotation annotation : entity.getAnnotations(ontology)) 
{
    System.out.println("\nannotation property->value: "+annotation.getProperty()+" -> "+annotation.getValue());
}
于 2014-09-02T13:27:21.043 回答