sevki kayir wrote:
> Hi there!
> Can any of you help me in getting the object values of
> an owl ontology. I am a new user of OWLApi and I want
> to parse an OWL ontology and get the object values of
> an individual in that ontology. The situation is that
> the object values are also individuals to which I can
> not reach. I can get the properties for the
> individuals but not the individuals that are the
> fillers of those properties. Maybe its solution is to
> parse the triples but I also can't do that. Could you
> please help me in my problem? Can you provide a sample
> code to access the triples and get the object values ?
You should be able to get the object values of an individual through the
getObjectPropertyValues(OWLOntology o)
method on OWLIndividual. This returns a Map which is keyed on
properties, with values sets of individuals. Some sample code (taken
from the RDF renderer) is as follows:
OWLIndividual ind;
OWLOntology ontology;
...
Map propertyValues = ind.getObjectPropertyValues( ontology );
for (Iterator it = propertyValues.keySet().iterator();
it.hasNext();) {
OWLObjectProperty prop = (OWLObjectProperty) it.next();
Set vals = (Set) propertyValues.get(prop);
for (Iterator valIt = vals.iterator(); valIt.hasNext();) {
OWLIndividual oi = (OWLIndividual) valIt.next();
pw.println(INDENT + "<"
+ shortForm(prop.getURI())
+ " rdf:resource=\""
+ oi.getURI()
+ "\"/>");
}
}
The Renderer implementations are a good place to look, in general to see
how one can access information within an ontology.
Sean
--
Sean Bechhofer
seanb@...
http://www.cs.man.ac.uk/~seanb
|