我有一个.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的类名(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()方法进行检索。

您可以使用OWLIndividual并调用OWLDataFactory来获取匹配的getOWLNamedIndividual()

关于java - OWLAPI:在AnnotationAssertion中获取IRI,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/37225126/

10-10 18:05