[英]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.