2014-10-05 35 views
0

假設以下示例(參見下圖):單個「bmw-x5」具有對象屬性斷言「has-type car」。此對象屬性具有值爲「4」的註釋屬性「wheels」。如何使用OWL API獲取對象屬性聲明的註釋

使用OWL API,我設法獲得了單個「bmw-x5」,對象屬性斷言「hastype car」。我現在堅持註解屬性「輪子」。我如何從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

回答

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);