[Pellet-users] SWRL in Pellet
sjtirtha
sjtirtha at gmail.com
Mon May 21 09:46:57 UTC 2007
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.
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 "));
OWLObjectProperty hasAunt = reasoner.getObjectProperty(URI.*create*(
"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(); }
####################################################################
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.owldl.com/pipermail/pellet-users/attachments/20070521/2d48e083/attachment.htm
More information about the Pellet-users
mailing list