[Pellet-users] SWRL in Pellet
Evren Sirin
evren at clarkparsia.com
Thu May 24 14:30:01 UTC 2007
On 5/21/07 5:46 AM, sjtirtha wrote:
> Hi,
>
> I've posted it once, but nobody answers.
>
> My code doesn't reason the rules, that I defined in family_rules.owl .
>
> I don't get any error. I assume that OWL API parses the rules correctly.
>
> Do I need to activate the rules engine inside the reasoner ? Is there
> anything like that.
No, rule reasoning is turned on by default. What you do below should get
the inferences caused by rules. If you could provide the rules file and
specify which inferences is missing then we can take a look.
Cheers,
Evren
>
> Steve
>
> ############################################################################
>
> String OWL_OBJ =
> "file:src/family_rules.owl"; *try* {
>
> System.
>
> /out/.println("Reading file " + OWL_OBJ + "..." );
>
> Reasoner reasoner =
>
> *new* Reasoner();
>
> OWLOntologyManager manager = OWLManager./createOWLOntologyManager/();
>
> OWLOntology ontology = manager.loadOntology(URI./create/(OWL_OBJ));
>
> reasoner.setManager(manager);
>
> reasoner.loadOntologies(ontology);
>
> reasoner.getKB().realize();
>
> reasoner.getKB().printClassTree();
>
> OWLClass human = reasoner.getClass(URI./create/(
>
> " http://www.w3c.org/swrl/family .owl#human
> <http://www.w3c.org/swrl/family.owl#human>" ));
>
> OWLObjectProperty hasUncle = reasoner.getObjectProperty(URI./create/(
>
> " http://www.w3c.org/swrl/family.owl#hasUncle
> <http://www.w3c.org/swrl/family.owl#hasUncle>"));
>
> OWLObjectProperty hasAunt = reasoner.getObjectProperty(URI./create/(
>
> " http://www.w3c.org/swrl/family.owl#hasAunt
> <http://www.w3c.org/swrl/family.owl#hasAunt>")); // get all instances
> of human class
>
> Set individuals = reasoner.getIndividuals(human,
>
> *false*);
>
> System.
>
> /out/.println("Size: " + individuals.size()); *for*(Iterator i =
> individuals.iterator(); i.hasNext(); ) {
>
> OWLIndividual ind = (OWLIndividual) i.next();
>
> Set uncles = reasoner.getRelatedIndividuals(ind, hasUncle);
>
> Set aunties = reasoner.getRelatedIndividuals(ind, hasAunt);
>
> // print the results
>
> System.
>
> /out/.println("Name: " + ind.getURI().toString());
>
> System.
>
> /out/.println("\tUncles: " + uncles.size());
>
> System.
>
> /out/.println("\tAunties: " + uncles.size()); /*
>
> if(uncles != null)
>
> System.out.println("\tUncle: " + uncles.getURI().toString());
>
> if(aunties != null)
>
> System.out.println("\tAunt: " + aunties.getURI().toString());
>
> */
>
> System.
>
> /out/.println();
> }
> ####################################################################
> ------------------------------------------------------------------------
>
> _______________________________________________
> Pellet-users mailing list
> Pellet-users at lists.owldl.com
> http://lists.owldl.com/mailman/listinfo/pellet-users
> _______________________________________________
>
> Sponsored by Clark & Parsia, LLC http://clarkparsia.com/
More information about the Pellet-users
mailing list