[英]Retrieve owl:restrictions using the OWL API
早上好,我正在使用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);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.