Retrieve Data Properties of An Individual using OWL API in eclipse

若如初见. 提交于 2019-12-11 14:25:43

问题


I want to retrieve all data properties set for an individual of any class using owl api. The code i have used is

OWLNamedIndividual inputNoun = df.getOWLNamedIndividual(IRI.create(prefix + "Cow"));


            for (OWLDataProperty prop: inputNoun.getDataPropertiesInSignature())
            {
               System.out.println("the properties for Cow are " + prop);    //line 1
            }

This code compiles with success but line 1 print nothing at all. What should be the correct syntax. Have thoroughly googled and couldnt find any thing worth it.


回答1:


OWLNamedIndividual::getDataPropertiesInSignature() does not return the properties for which the individual has a filler, it returns the properties that appear in the object itself. For an individual this is usually empty. The method is on the OWLObject interface, which covers things like class and property expressions and ontologies, for which it has a more useful output.

If you want the data properties with an actual filler for an individual, use OWLOntology::getDataPropertyAssertionAxioms(OWLIndividual), like this:

OWLNamedIndividual input = ...
Set<OWLDataPropertyAssertionAxiom> properties=ontology.getDataPropertyAssertionAxioms(input);
for (OWLDataPropertyAssertionAxiom ax: properties) {
    System.out.println(ax.getProperty());
}


来源:https://stackoverflow.com/questions/25949745/retrieve-data-properties-of-an-individual-using-owl-api-in-eclipse

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!