Hi all,
I tried to run the GenericRuleReasoner example I found in the "Jena 2 interface
support page" and I get no results from the reasoner.
Following is my code:
PrintUtil.registerPrefix("eg", "urn:x-hp:eg/");
Model model = ModelFactory.createDefaultModel();
model.setNsPrefix("eg", "urn:x-hp:eg/");
Statement st;
Property p = model.createProperty("eg:p");
Resource objA = model.createResource("eg:A");
Resource objB = model.createResource("eg:B");
Resource objC = model.createResource("eg:C");
Resource objD = model.createResource("eg:D");
st = model.createStatement(objA, p, objB );
model.add(st);
st = model.createStatement(objB, p, objC );
model.add(st);
st = model.createStatement(objC, p, objD );
model.add(st);
String rules = "[rule1: (?a eg:p ?b) (?b eg:p ?c) -> (?a eg:p ?c)]";
GenericRuleReasoner reasoner = new
GenericRuleReasoner(Rule.parseRules(rules));
reasoner.setDerivationLogging(true);
reasoner.setTraceOn(true);
InfModel inf = ModelFactory.createInfModel(reasoner, model);
PrintWriter out = new PrintWriter(System.out);
for (StmtIterator i = inf.listStatements(objA, p, objD); i.hasNext();
) {
Statement s = i.nextStatement();
System.out.println("Statement is " + s);
for (Iterator<Derivation> id = inf.getDerivation(s);
id.hasNext(); ) {
Derivation deriv = (Derivation) id.next();
deriv.printTrace(out, true);
}
}
out.flush();
Help please ?
Thanks in advance,
Lior Barnea.
________________________________
The content of this e-mail (including any attachments hereto) is confidential
and contains proprietary information of the sender. This e-mail is intended
only for the use of the individual and entities listed above. If the reader of
this message is not the intended recipient, you are hereby notified that any
dissemination, distribution or copying of this communication (and any
information or attachment contained herein) is strictly prohibited. If you have
received this communication in error, please notify us immediately by telephone
or by e-mail and delete the message (including the attachments hereto) from
your computer. Thank you!!