简体   繁体   English

如何使用OWL API获取对象属性声明的注释

[英]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". 假定以下示例(请参见下图):单个“ bmw-x5”具有对象属性声明“ has-type car”。 This object property has an annotation property "wheels" with value "4". 该对象属性的注释属性“ wheels”的值为“ 4”。

Using OWL API, I managed to get the individual "bmw-x5", the object property assertion "hastype car". 使用OWL API,我设法获得了单独的“ bmw-x5”,即对象属性断言“ hastype car”。 I am now stuck with the annotation property "wheels". 我现在停留在注释属性“ wheels”上。 How can I get its value from the OWL API? 如何从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);

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

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