Source Code Cross Referenced for OWLExptRuleReasoner.java in  » RSS-RDF » Jena-2.5.5 » com » hp » hpl » jena » reasoner » rulesys » impl » oldCode » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » RSS RDF » Jena 2.5.5 » com.hp.hpl.jena.reasoner.rulesys.impl.oldCode 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /******************************************************************
002:         * File:        OWLExptRuleReasoner.java
003:         * Created by:  Dave Reynolds
004:         * Created on:  10-Jul-2003
005:         * 
006:         * (c) Copyright 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
007:         * [See end of file]
008:         * $Id: OWLExptRuleReasoner.java,v 1.11 2008/01/02 12:09:44 andy_seaborne Exp $
009:         *****************************************************************/package com.hp.hpl.jena.reasoner.rulesys.impl.oldCode;
010:
011:        import java.util.*;
012:        import org.apache.commons.logging.Log;
013:        import org.apache.commons.logging.LogFactory;
014:
015:        import com.hp.hpl.jena.reasoner.*;
016:        import com.hp.hpl.jena.reasoner.rulesys.FBRuleInfGraph;
017:        import com.hp.hpl.jena.reasoner.rulesys.FBRuleReasoner;
018:        import com.hp.hpl.jena.reasoner.rulesys.Rule;
019:        import com.hp.hpl.jena.reasoner.rulesys.Util;
020:        import com.hp.hpl.jena.reasoner.rulesys.impl.OWLRuleTranslationHook;
021:        import com.hp.hpl.jena.shared.WrappedIOException;
022:        import com.hp.hpl.jena.graph.*;
023:
024:        /**
025:         * A hybrid forward/backward implementation of the OWL closure rules - experimental variant.
026:         * 
027:         * @author <a href="mailto:der@hplb.hpl.hp.com">Dave Reynolds</a>
028:         * @version $Revision: 1.11 $ on $Date: 2008/01/02 12:09:44 $
029:         */
030:        public class OWLExptRuleReasoner extends FBRuleReasoner {
031:
032:            /** The location of the OWL rule definitions on the class path */
033:            protected static final String RULE_FILE = "etc/owl-fb.rules";
034:
035:            /** The parsed rules */
036:            protected static List ruleSet;
037:
038:            /** The precomputed axiom closure and compiled rule set */
039:            protected static FBRuleInfGraph preload;
040:
041:            /** Flag, set to true to use the LP engine */
042:            private static final boolean USE_LP = true;
043:
044:            protected static Log logger = LogFactory
045:                    .getLog(OWLExptRuleReasoner.class);
046:
047:            /**
048:             * Constructor
049:             */
050:            public OWLExptRuleReasoner(ReasonerFactory factory) {
051:                super (loadRules(), factory);
052:
053:            }
054:
055:            /**
056:             * Internal constructor, used to generated a partial binding of a schema
057:             * to a rule reasoner instance.
058:             */
059:            private OWLExptRuleReasoner(OWLExptRuleReasoner parent,
060:                    InfGraph schemaGraph) {
061:                super (parent.rules, schemaGraph, parent.factory);
062:            }
063:
064:            /**
065:             * Return the rule set, loading it in if necessary
066:             */
067:            public static List loadRules() {
068:                if (ruleSet == null) {
069:                    try {
070:                        ruleSet = Rule.parseRules(Util
071:                                .loadRuleParserFromResourceFile(RULE_FILE));
072:                    } catch (WrappedIOException e) {
073:                        throw new ReasonerException("Can't load rules file: "
074:                                + RULE_FILE, e);
075:                    }
076:                }
077:                return ruleSet;
078:            }
079:
080:            /**
081:             * Precompute the implications of a schema graph. The statements in the graph
082:             * will be combined with the data when the final InfGraph is created.
083:             */
084:            public Reasoner bindSchema(Graph tbox) throws ReasonerException {
085:                if (schemaGraph != null) {
086:                    throw new ReasonerException(
087:                            "Can only bind one schema at a time to an OWLRuleReasoner");
088:                }
089:                FBRuleInfGraph graph = makeInfGraph(rules, tbox, true);
090:                graph.addPreprocessingHook(new OWLRuleTranslationHook());
091:                graph.prepare();
092:                return new OWLExptRuleReasoner(this , graph);
093:            }
094:
095:            /**
096:             * Attach the reasoner to a set of RDF data to process.
097:             * The reasoner may already have been bound to specific rules or ontology
098:             * axioms (encoded in RDF) through earlier bindRuleset calls.
099:             * 
100:             * @param data the RDF data to be processed, some reasoners may restrict
101:             * the range of RDF which is legal here (e.g. syntactic restrictions in OWL).
102:             * @return an inference graph through which the data+reasoner can be queried.
103:             * @throws ReasonerException if the data is ill-formed according to the
104:             * constraints imposed by this reasoner.
105:             */
106:            public InfGraph bind(Graph data) throws ReasonerException {
107:                FBRuleInfGraph graph = null;
108:                InfGraph schemaArg = schemaGraph == null ? getPreload()
109:                        : (FBRuleInfGraph) schemaGraph;
110:                List baseRules = ((FBRuleInfGraph) schemaArg).getRules();
111:                graph = makeInfGraph(baseRules, schemaArg, false);
112:                graph.addPreprocessingHook(new OWLRuleTranslationHook());
113:                graph.setDerivationLogging(recordDerivations);
114:                graph.setTraceOn(isTraceOn());
115:                graph.rebind(data);
116:
117:                return graph;
118:            }
119:
120:            /**
121:             * Get the single static precomputed rule closure.
122:             */
123:            public InfGraph getPreload() {
124:                synchronized (OWLExptRuleReasoner.class) {
125:                    if (preload == null) {
126:                        preload = makeInfGraph(rules, null, false);
127:                        preload.prepare();
128:                    }
129:                    return preload;
130:                }
131:            }
132:
133:            /**
134:             * Construct an FB rule infgraph variant. Allows switching between the normal
135:             * and LP implementations during development.
136:             */
137:            private FBRuleInfGraph makeInfGraph(List rules, Graph schema,
138:                    boolean doPreload) {
139:                if (USE_LP) {
140:                    if (doPreload) {
141:                        return new FBRuleInfGraph(this , rules, getPreload(),
142:                                schema);
143:                    } else {
144:                        return new FBRuleInfGraph(this , rules, schema);
145:                    }
146:                } else {
147:                    if (doPreload) {
148:                        return new FBRuleInfGraph(this , rules, getPreload(),
149:                                schema);
150:                    } else {
151:                        return new FBRuleInfGraph(this , rules, schema);
152:                    }
153:                }
154:            }
155:        }
156:
157:        /*
158:         (c) Copyright 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
159:         All rights reserved.
160:
161:         Redistribution and use in source and binary forms, with or without
162:         modification, are permitted provided that the following conditions
163:         are met:
164:
165:         1. Redistributions of source code must retain the above copyright
166:         notice, this list of conditions and the following disclaimer.
167:
168:         2. Redistributions in binary form must reproduce the above copyright
169:         notice, this list of conditions and the following disclaimer in the
170:         documentation and/or other materials provided with the distribution.
171:
172:         3. The name of the author may not be used to endorse or promote products
173:         derived from this software without specific prior written permission.
174:
175:         THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
176:         IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
177:         OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
178:         IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
179:         INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
180:         NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
181:         DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
182:         THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
183:         (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
184:         THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
185:         */
ww__w___.ja__v___a__2_s_.__co__m___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.