2014-10-04 49 views
0

我正在使用owl api 4.0,下面的代码会给我属于类Animal的所有属性。如何检索OWL API 4.0中的数据属性的子属性

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

既然您使用本体的推理器,我假设您想要所有的子属性,无论是断言还是推断。 的推理可以做的工作:

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

我用这个代码,并与现在发出 – learner 2014-10-06 09:09:06

+0

相应的修改我的问题,你能否告诉本体,或再现这一问题的片段,以及您所使用的推理? owlapi方面看起来不错,可能是推理者的错误或本体的问题。 – Ignazio 2014-10-06 13:18:41

+0

好的。我的坏我可以检索子属性。这个owlbottomDataProperty显示为其子属性未定义的属性。你的回答确实是对的:) – learner 2014-10-07 19:16:56