You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

为何OWLAPI代码无法获取OWLOntology的dc:title注释值?

问题原因及解决方案

你代码的核心问题是把本体IRI错误地当成了OWL个体(OWLNamedIndividual),但实际上<http://www.adventium.com/aadl>是本体(owl:Ontology)的IRI,不属于个体类型的实体,所以通过EntitySearcher.getAnnotations(ontologyIndividual, ...)找不到对应的注释。

正确实现代码

要获取本体的dc:title注释,直接从OWLOntology对象本身获取即可,无需将其当作个体处理:

OWLOntology owlOntology = manager.loadOntologyFromOntologyDocument(workingIRI);
OWLAnnotationProperty titleAnnotation = dataFactory.getOWLAnnotationProperty(IRI.create("http://purl.org/dc/elements/1.1#title"));

// 直接获取本体的所有title注释
Stream<OWLAnnotation> titleAnnotations = owlOntology.getAnnotations(titleAnnotation);
List<OWLAnnotation> titleAnnotationList = titleAnnotations.toList();

for (OWLAnnotation annotation : titleAnnotationList) {
    if (annotation.getValue() instanceof OWLLiteral literal) {
        System.err.println("title " + literal.getLiteral());
    }
}

补充说明

  • OWL中,本体(owl:Ontology)是特殊的元实体,不属于个体(NamedIndividual)范畴,不能用getOWLNamedIndividual()创建对应实体对象。
  • 修正后的代码直接调用owlOntology.getAnnotations(titleAnnotation),可精准获取本体上绑定的dc:title注释,输出预期的"AADL Language Terms"。

内容的提问来源于stack exchange,提问作者Steve Vestal

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.18 03:14:56