我正在使用 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
这里有什么问题?