1 10 package com.hp.hpl.jena.reasoner.rulesys.test; 11 12 import com.hp.hpl.jena.reasoner.rulesys.*; 13 import com.hp.hpl.jena.mem.GraphMem; 14 import com.hp.hpl.jena.reasoner.*; 15 import com.hp.hpl.jena.graph.*; 16 import com.hp.hpl.jena.util.PrintUtil; 17 18 import java.util.*; 19 import java.io.*; 20 21 25 public class DebugRules { 26 27 28 public static final String ruleFile = "etc/temp.rules"; 29 30 31 public List ruleset; 32 33 34 public DebugRules(String rulefileName) throws IOException { 35 ruleset = Rule.parseRules(Util.loadRuleParserFromResourceFile(rulefileName)); 36 } 37 38 39 public void run() { 40 41 BasicForwardRuleReasoner reasoner = new BasicForwardRuleReasoner(ruleset); 42 InfGraph result = reasoner.bind(new GraphMem()); 43 System.out.println("Final graph state"); 44 for (Iterator i = result.find(null, null, null); i.hasNext(); ) { 45 System.out.println(PrintUtil.print((Triple)i.next())); 46 } 47 48 } 49 50 public static void main(String [] args) { 51 try { 52 DebugRules tester = new DebugRules(ruleFile); 53 tester.run(); 54 } catch (Exception e) { 55 System.out.println("Problem: " + e); 56 } 57 } 58 59 } 60 61 87 | Popular Tags |