简体   繁体   English

OWLAPI:在 AnnotationAssertion 中获取 IRI

[英]OWLAPI: Get the IRI in a AnnotationAssertion

I have an .owl file like this:我有一个像这样的 .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>

What I would like to get, is the class name (BusinessProcess) for the named individual IRI that is declared in the annotation assertion (#bf1badca)我想得到的是在注释断言 (#bf1badca) 中声明的命名个人 IRI 的类名 (BusinessProcess)

I have the following code that can access the value of the literal in the annotation:我有以下代码可以访问注释中的文字值:

        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'
              }

        };

How can access the IRI field of the annotation assertion, ie, the value #bf1badca?如何访问注释断言的IRI 字段,即#bf1badca 值?

The IRI field is the subject of the annotation axiom and can be retrieved with the getSubject() method. IRI 字段是注释公理的主题,可以使用getSubject()方法检索。

You can get the matching OWLIndividual using an OWLDataFactory and calling getOWLNamedIndividual() .您可以使用OWLDataFactory并调用getOWLNamedIndividual()来获取匹配的OWLIndividual

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM