如何使用OWL API获取对象属性断言的注释

时间:2014-10-05 15:13:50

标签: java owl ontology owl-api

假设以下示例(见下图):个人" bmw-x5"具有对象属性断言" has-type car"。此对象属性具有注释属性" wheels"有价值" 4"。

使用OWL API,我设法获得个人" bmw-x5",对象属性断言" hastype car"。我现在坚持使用注释属性" wheels"。如何从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>

enter image description here

1 个答案:

答案 0 :(得分:0)

如果你掌握了一个对象属性断言公理,那么注释可用如下:

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

为了访问某个人的所有对象属性断言公理,您可以使用:

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