OWLAPI:在 AnnotationAssertion 中获取 IRI

OWLAPI: Get the IRI in a AnnotationAssertion

我有一个这样的 .owl 文件:

...

<ClassAssertion>
    <Class IRI="http://timbus.teco.edu/ontologies/DIO.owl#BusinessProcess"/>
    <NamedIndividual IRI="#bf1badca"/>
</ClassAssertion>

...

<AnnotationAssertion>
    <AnnotationProperty abbreviatedIRI="rdfs:label"/>
    <IRI>#bf1badca</IRI>
    <Literal datatypeIRI="http://www.w3.org/2001/XMLSchema#string">Remove_old_books</Literal>
</AnnotationAssertion>

我想得到的是在注解断言 (#bf1badca)

中声明的指定个人 IRI 的 class 名称 (BusinessProcess)

我有以下代码可以访问注释中文字的值:

        OWLOntologyWalker walker = new OWLOntologyWalker(Collections.singleton(ontology));

        OWLOntologyWalkerVisitor visitor = new OWLOntologyWalkerVisitor(walker) {

            @Override
              public void visit(OWLAnnotationAssertionAxiom axiom) {
                OWLLiteral val = (OWLLiteral)axiom.getValue();
                System.out.println(val.getLiteral());
                // Prints 'Remove_old_books'
              }

        };

如何访问注释断言的 IRI 字段,即值 #bf1badca?

IRI 字段是注释公理的主题,可以使用getSubject() 方法检索。

您可以使用 OWLDataFactory 并调用 getOWLNamedIndividual().

获得匹配的 OWLIndividual