Retrieve Data Properties of An Individual using OW

2019-09-12 15:09发布

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条回答
家丑人穷心不美
2楼-- · 2019-09-12 15:39

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());
}
查看更多
登录 后发表回答