早上好,我正在使用 OWL API,我正在尝试检索 owl:Restriction 内的数据。例如,我正在使用披萨本体,我想获取 onProperty 和 someValuesFrom 的数据,这是
的一部分<owl:Class rdf:about="#American">
<rdfs:label xml:lang="pt">Americana</rdfs:label>
<rdfs:subClassOf>
<owl:Restriction>
<owl:onProperty rdf:resource="#hasTopping"/>
<owl:someValuesFrom rdf:resource="#TomatoTopping"/>
</owl:Restriction>
</rdfs:subClassOf>
...
</owl:Class>
因此,如果我有美国 OWLClass,我怎样才能获得 OwlRestrictions 及其适用的属性的列表。类似于 American -> subClassOf -> Restriction -> onProperty -> hasTopping。有没有办法创建一个包含所有这些步骤的数据结构?
最佳答案
我不确定你所说的“步骤”到底是什么意思,但我认为你有一个类,并且你需要适用于子类的所有限制。但是,如果您还希望对同等类应用限制,会发生什么情况?因此,我想写一个更通用的。这里是:
PrefixManager pm= new DefaultPrefixManager("http://www.co-ode.org/ontologies/pizza/pizza.owl#");
OWLClass american=factory.getOWLClass("American", pm);
Set<OWLClassAxiom> tempAx=localOntology.getAxioms(american);
for(OWLClassAxiom ax: tempAx){
for(OWLClassExpression nce:ax.getNestedClassExpressions())
if(nce.getClassExpressionType()!=ClassExpressionType.OWL_CLASS)
System.out.println(ax);
}
关于java - 检索猫头鹰 :restrictions using the OWL API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28968495/