I have an .owl file like this:
...
<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)
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?
The IRI field is the subject of the annotation axiom and can be retrieved with the getSubject()
method.
You can get the matching OWLIndividual
using an OWLDataFactory
and calling getOWLNamedIndividual()
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.