01: /******************************************************************
02: * File: DebugRules.java
03: * Created by: Dave Reynolds
04: * Created on: 15-Apr-2003
05: *
06: * (c) Copyright 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
07: * [See end of file]
08: * $Id: DebugRules.java,v 1.10 2008/01/02 12:08:19 andy_seaborne Exp $
09: *****************************************************************/package com.hp.hpl.jena.reasoner.rulesys.test;
10:
11: import com.hp.hpl.jena.reasoner.rulesys.*;
12: import com.hp.hpl.jena.reasoner.*;
13: import com.hp.hpl.jena.graph.*;
14: import com.hp.hpl.jena.util.PrintUtil;
15:
16: import java.util.*;
17: import java.io.*;
18:
19: /** * Using during debuging of the rule systems.
20: * Runs a named set of rules (can contain axioms and rules) and
21: * lists all the resulting entailments.
22: * * @author <a href="mailto:der@hplb.hpl.hp.com">Dave Reynolds</a> * @version $Revision: 1.10 $ on $Date: 2008/01/02 12:08:19 $ */
23: public class DebugRules {
24:
25: /** The name of the rule set to load */
26: public static final String ruleFile = "etc/temp.rules";
27:
28: /** The parsed set of rules */
29: public List ruleset;
30:
31: /** Constructor - loads the rules */
32: public DebugRules(String rulefileName) throws IOException {
33: ruleset = Rule.parseRules(Util
34: .loadRuleParserFromResourceFile(rulefileName));
35: }
36:
37: /** Run a single test */
38: public void run() {
39:
40: BasicForwardRuleReasoner reasoner = new BasicForwardRuleReasoner(
41: ruleset);
42: InfGraph result = reasoner.bind(Factory.createGraphMem());
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: /*
62: * (c) Copyright 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
63: * All rights reserved.
64: *
65: * Redistribution and use in source and binary forms, with or without
66: * modification, are permitted provided that the following conditions
67: * are met:
68: * 1. Redistributions of source code must retain the above copyright
69: * notice, this list of conditions and the following disclaimer.
70: * 2. Redistributions in binary form must reproduce the above copyright
71: * notice, this list of conditions and the following disclaimer in the
72: * documentation and/or other materials provided with the distribution.
73: * 3. The name of the author may not be used to endorse or promote products
74: * derived from this software without specific prior written permission.
75: *
76: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
77: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
78: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
79: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
80: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
81: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
82: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
83: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
84: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
85: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
86: */
|