假设我有一个名为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. 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);
答案 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
)
);