[英]How to get annotations from owl individual using OWLAPI
我已经知道如何从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());
}
我得到了解决方案:我必须将个人转换为OWLEntity:
OWLEntity entity = (OWLEntity)individual;
for (OWLAnnotation annotation : entity.getAnnotations(ontology))
{
System.out.println("\nannotation property->value: "+annotation.getProperty()+" -> "+annotation.getValue());
}
一般的解决方案是使用OWLOntology.getAnnotationAssertionAxioms(OWLAnnotationSubject)
它适用于实体和匿名个人。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.