我有一个对象属性Car和它的子属性作为法拉利。我想获得超级财产,即带有猫头鹰api 4的法拉利汽车。我可以获得房产的子房产而不是超级房产。我错过了什么api?
答案 0 :(得分:2)
如果直接断言子属性关系,则可以使用OWLOntology::getObjectSubPropertyAxiomsForSubProperty方法。
示例:
OWLOntology o = ...
OWLObjectProperty p = ...
o.getObjectSubPropertyAxiomsForSubProperty(p);
答案 1 :(得分:0)
我可以通过以下方式执行此操作: -
Set<OWLObjectProperty> props = ont.getObjectPropertiesInSignature();
for (OWLObjectProperty p : props) {
HashSet<OWLSubObjectPropertyOfAxiom> subPropertySet = (HashSet)ont.getObjectSubPropertyAxiomsForSuperProperty(p);
for (OWLSubObjectPropertyOfAxiom subPropAxiom : subPropertySet) {
OWLObjectPropertyExpression subObjectProperty = subPropAxiom.getSubProperty();
if (subObjectProperty.getNamedProperty().getIRI().equals(relationIRI)) {
d.setDerivedFrom(p.getIRI().getShortForm());
}
}
}
如果有更好的方法,请告诉我。
答案 2 :(得分:0)
Iterator<OWLSubObjectPropertyOfAxiom> subItr = ont.getObjectSubPropertyAxiomsForSubProperty(factory.getOWLObjectProperty(relationIRI)).iterator();
while (subItr.hasNext()) {
OWLSubObjectPropertyOfAxiom subPropAxiom = subItr.next();
d.setDerivedFrom(subPropAxiom.getSuperProperty().getNamedProperty().getIRI().getShortForm());
}
只是添加到西蒙的答案......这对我来说很好....