使用推理器获取枚举值

Get enumerated values with a reasoner

假设我有一个名为 fooType 的数据 属性 有 2 个可能的值 {"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(获取"Low"和"High")
  2. 获取给定个体的所有 fooType 值?

到目前为止,我已经尝试并卡住了:

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

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

要访问所有范围及其组件:

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