如何在OWL API 4.0中检索数据属性的子属性

时间:2014-10-04 21:13:13

标签: eclipse java-7 owl-api

我正在使用owl api 4.0,以下代码将为我提供属于Animal类的个人的所有属性。

OWLClass animalCl = df.getOWLClass(IRI.create(ontologyIRI + "Animal"));
NodeSet<OWLNamedIndividual> animalIndl = reasoner.getInstances(animalCl, false);

for (OWLNamedIndividual animalNamedIndl : animalIndl.getFlattened())
 {
 Set<OWLDataPropertyAssertionAxiom> propAll=    myontology.getDataPropertyAssertionAxioms(animalNamedIndl);  
 for (OWLDataPropertyAssertionAxiom ax: propAll)   
   {
     for (OWLLiteral propertyLit :  EntitySearcher.getDataPropertyValues(animalNamedIndl, ax.getProperty(), myontolgoy))
     System.out.println("The property " + ax.getProperty() + "has value" + propertyLit);  
      }  
}

我为每个数据属性都有一个子属性“propWt”。我使用了以下代码: -

NodeSet<OWLDataProperty> properties = reasoner.getSubDataProperties((OWLDataProperty) ax.getProperty(), false);
for (OWLDataProperty mysubproperty : properties.getFlattened())
    {
     System.out.println("the sub property is " + mysubproperty);
    }

而不是

the sub property is <http://localhost:3030/BiOnt.owl#propWt>

我得到了

 the sub property is owl:bottomDataProperty

这里有什么问题?

1 个答案:

答案 0 :(得分:1)

由于您正在使用本体的推理器,我假设您需要所有子属性,无论是断言还是推断。 推理者可以胜任:

NodeSet<OWLDataProperty> properties = reasoner.getSubDataProperties(property, false);