简体   繁体   中英

How to get annotations of object property assertions using OWL API

Assume the following example (see image below): an individual "bmw-x5" has the object property assertion "has-type car". This object property has an annotation property "wheels" with value "4".

Using OWL API, I managed to get the individual "bmw-x5", the object property assertion "hastype car". I am now stuck with the annotation property "wheels". How can I get its value from the OWL API?

    <ObjectPropertyAssertion>
        <Annotation>
            <AnnotationProperty IRI="#wheels"/>
            <Literal datatypeIRI="&rdf;PlainLiteral">4</Literal>
        </Annotation>
        <ObjectProperty IRI="#has-type"/>
        <NamedIndividual IRI="#bmw-x5"/>
        <NamedIndividual IRI="#car"/>
    </ObjectPropertyAssertion>

在此处输入图片说明

If you have got hold of an object property assertion axiom, then the annotations are available as follows:

OWLObjectAssertionAxiom axiom = ...
for(OWLAnnotation a: axiom.getAnnotations()) {
    // this cycle will go over all annotations, with annotation property and annotation value
}

In order to access all object property assertion axioms for a certain individual, you can use:

Set<OWLObjectAssertionAxiom> set = ontology.getObjectPropertyAssertionAxioms(individual);

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.

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