使用推理器获取枚举值

时间:2017-05-23 11:24:34

标签: owl ontology protege owl-api reasoning

假设我有一个名为fooType的数据属性,其中包含两个可能的值{"Low", "High"}

<DataPropertyRange>
    <DataProperty IRI="#fooType"/>
    <DataOneOf>
        <Literal datatypeIRI="http://www.w3.org/1999/02/22-rdf-syntax-ns#PlainLiteral">Low</Literal>
        <Literal datatypeIRI="http://www.w3.org/1999/02/22-rdf-syntax-ns#PlainLiteral">High</Literal>
    </DataOneOf>
</DataPropertyRange>

我如何使用owlapi和推理器:

  1. 获取所有范围的数据属性fooType(获取&#34;低&#34;和&#34;高&#34;)
  2. 获取给定个人的所有fooType值?
  3. 到目前为止,我已经尝试过了:

    // 1. How to get "Low" and "High" strings in the next step?
    OWLDataProperty dataProperty = ...
    Set<OWLDataPropertyRangeAxiom> dataPropertyRangeAxioms = ontology.getDataPropertyRangeAxioms(dataProperty);
    
    // 2. How to get fooType's values in the next step?
    OWLIndividual individual = ...
    Set<OWLLiteral> literals = reasoner.getDataPropertyValues(individual, dataProperty);
    

1 个答案:

答案 0 :(得分:1)

没有必要列出所有枚举值的推理器 - 例如,它不会列出未使用但允许在枚举中使用的值。

访问所有范围及其组件:

OWLOntology o = ...
OWLDataProperty p = ...
o.dataPropertyRangeAxioms(p)
    .map(OWLDataPropertyRangeAxiom::getRange)
    .forEach((OWLDataRange range) -> 
        // this is where you can visit all ranges
        // using an OWLDataRangeVisitor
    )
);