From: Cédric P. <ced...@gm...> - 2009-09-23 14:04:27
|
Hello, I have a question about the use of reasoner to retrieve individuals. My example is based on the pizza ontology ( http://www.co-ode.org/ontologies/pizza/2007/02/12/ ) wherein some pizzas (like margherita) are classes and ingredients are (like mozzarella) are also classes. In order to learn how to use a reasoner (in this case Pellet) I wanted to begin with a simple program to retrieve pizzas thanks to specific ingredients. Here is an example where I'm asking which pizzas has ham as an ingredient (more precisely as a topping). [code] Set<OWLDescription> descrCollection = new HashSet<OWLDescription>(); OWLDataFactory dataFactory = manager.getOWLDataFactory(); OWLObjectPropertyExpression prop = dataFactory.getOWLObjectProperty(URI.create(ontology.getURI().toString()+"#"+"hasTopping")); OWLDescription topping = dataFactory.getOWLClass(URI.create(ontology.getURI().toString()+"#"+"HamTopping")); OWLDescription toppingDesc = dataFactory.getOWLObjectSomeRestriction(prop, topping); OWLDescription wantedDesc = manager.getOWLDataFactory().getOWLObjectIntersectionOf(descrCollection); // Ask the reasoner for the subclasses of the description try { System.out.println(reasoner.getSubClasses(toppingDesc)); } catch(OWLReasonerException e) { e.printStackTrace(); } [/code] The result printed is "[[Parmense], [Capricciosa], [LaReine], [Siciliana]]" and it is what I was expecting. Now my question is: if pizzas and ingredients are changed into individuals instead of classes (magherita as an individual of the class Pizza and ham as an individual as the class Topping, etc…), how can I adapt (if it’s possible) this code in order to obtain the same results? I was thinking about changing "topping = dataFactory.getOWLClass(...)" into " topping = dataFactory.getOWLIndividual(...)" and "reasoner.getSubClasses(toppingDesc)" by "reasoner.getIndividuals(toppingDesc, false)" but it's not working because dataFactory.getOWLIndividual does not return any OWLDescription as needed (and a cast seems not feasible). Than you in advance for you help. Regards, Cedric |