On 15/06/14 07:09, Adeeb Noor wrote:
Hi All:
I have been trying to use the backward jena rule engine was not able to for
some reasons. I have already applied the forward one and works just fine.
Here is the code:
public class Ruleset {
private List<Rule> rules = null;
private GenericRuleReasoner reasoner = null;
public Ruleset (String rulesSource){
this.rules = Rule.rulesFromURL(rulesSource);
this.reasoner = new GenericRuleReasoner(rules);
reasoner.setOWLTranslation(true);
reasoner.setTransitiveClosureCaching(true);}
public InfModel applyto(Model mode){
return ModelFactory.createInfModel(reasoner, mode);
}
public static void main(String[] args) {
Ruleset rule = new Ruleset (rulepath);
InfModel infmodel = rule.applyto(data.tdb);}
and here is my forward rule:
[test1: (?drug2 ddids:drug_is_metabolized_by_enzyme ddidd:C1176140)
->(?drug2 rdf:type ddids:hasInteraction)]
After running the rule above, I got result. However, when I tried to make
the same rule backward, I got nothing
[test2: (?drug2 rdf:type ddids:hasInteraction)
<-
(?drug2 ddids:drug_is_metabolized_by_enzyme ddidd:C1176140) ]
Am I doing something wrong here ?
Nothing obvious.
Your code as shown doesn't seem to set the ruleMode so it should be
defaulting to "hybrid" which means both forward and backward rules are
supported.
Presumably you have other rules so there can be "layering" interactions
where some deductions are made by backward rules instead of forward
rules and so not visible to the forward rules. That can cause a forward
rule to not fire in cases where a backward rule would. However, the
other way round, a backward rule not working where an equivalent forward
rule does, can't be due to layering.
The thing to do will be to create a minimal test case:
- reduce your data to a minimum (e.g. just one assertion matching
ddids:drug_is_metabolized_by_enzyme ddidd:C1176140)
- cut your rule set to a minimum (e.g. just that rule)
- create a minimal standalone driver code
Hopefully you will find that works and you can then work back up to see
where the problem arises in your real system.
If that minimal test fails then you have a runnable test case you can
share with us.
Dave