0

我正在使用 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

这里有什么问题?

4

1 回答 1

1

由于您使用本体的推理器,我假设您想要所有子属性,无论是断言的还是推断的。推理机可以完成这项工作:

NodeSet<OWLDataProperty> properties = reasoner.getSubDataProperties(property, false);
于 2014-10-05T18:15:19.800 回答