早上好,我正在使用OWL,我正在尝试检索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和它适用的属性。类似于美国-> subClassOf -> -> onProperty -> hasTopping。是否有一种方法可以创建包含所有这些步骤的数据结构?
发布于 2015-03-10 22:06:43
我不知道您所说的“步骤”到底是什么意思,但是我认为您有一个类,您需要所有适用于子类的限制。但是,如果您也希望对等效类应用限制,会发生什么情况?因此,我想写一个更一般的。下面是:
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);
}https://stackoverflow.com/questions/28968495
复制相似问题