com.hp.hpl.jena.reasoner.rulesys
Class GenericRuleReasoner

java.lang.Object
  extended by com.hp.hpl.jena.reasoner.rulesys.FBRuleReasoner
      extended by com.hp.hpl.jena.reasoner.rulesys.GenericRuleReasoner
All Implemented Interfaces:
Reasoner, RuleReasoner
Direct Known Subclasses:
DAMLMicroReasoner, OWLMicroReasoner, OWLMiniReasoner, RDFSForwardRuleReasoner, RDFSRuleReasoner

public class GenericRuleReasoner
extends FBRuleReasoner

A reasoner interface that is able to invoke any of the useful rule engine combinations. The rule set can be set after the reasoner instance is created. The mode can be set to forward, backward or hybrid. The OWL-specific rule augmentation can be included. Each of these settings can be controlled using the configuration graph, specific methods calls or generic setParameter calls.

Version:
$Revision: 1.2 $ on $Date: 2009/08/02 15:06:55 $
Author:
Dave Reynolds

Nested Class Summary
static class GenericRuleReasoner.RuleMode
          Class used as an enum for describing rule modes.
 
Field Summary
static GenericRuleReasoner.RuleMode BACKWARD
          Constant - the mode description for pure backward chaining
 boolean filterFunctors
          Flag, if true then find results will be filtered to remove functors and illegal RDF
static GenericRuleReasoner.RuleMode FORWARD
          Constant - the mode description for pure forward chaining
static GenericRuleReasoner.RuleMode FORWARD_RETE
          Constant - the mode description for pure forward chaining, using RETE engine
static GenericRuleReasoner.RuleMode HYBRID
          Constant - the mode description for mixed forward/backward, this is the default mode
 
Constructor Summary
GenericRuleReasoner(java.util.List<Rule> rules)
          Constructor.
GenericRuleReasoner(java.util.List<Rule> rules, ReasonerFactory factory)
          Constructor
GenericRuleReasoner(ReasonerFactory factory, Resource configuration)
          Constructor
 
Method Summary
 void addPreprocessingHook(RulePreprocessHook hook)
          Add a new preprocessing hook defining an operation that should be run when the inference graph is being prepared.
 InfGraph bind(Graph data)
          Attach the reasoner to a set of RDF data to process.
 Reasoner bindSchema(Graph tbox)
          Precompute the implications of a schema graph.
 void removePreprocessingHook(RulePreprocessHook hook)
          Remove a preprocessing hook.
 void setFunctorFiltering(boolean param)
          Set to true to cause functor-valued literals to be dropped from rule output.
 void setMode(GenericRuleReasoner.RuleMode mode)
          Set the direction of rule inference desired.
 void setOWLTranslation(boolean enableOWLTranslation)
          Set to true to enable translation of selected parts of an OWL schema to additional rules.
 void setRules(java.util.List<Rule> rules)
          Set (or change) the rule set that this reasoner should execute.
 void setTransitiveClosureCaching(boolean enableTGCCaching)
          Set to true to enable caching of subclass/subproperty lattices in a specialized cache rather than using the rule systems.
 
Methods inherited from class com.hp.hpl.jena.reasoner.rulesys.FBRuleReasoner
addDescription, addRules, bindSchema, getBoundSchema, getGraphCapabilities, getReasonerCapabilities, getRules, isTraceOn, loadRules, setDerivationLogging, setParameter, setTraceOn, supportsProperty, tablePredicate
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

filterFunctors

public boolean filterFunctors
Flag, if true then find results will be filtered to remove functors and illegal RDF


FORWARD

public static final GenericRuleReasoner.RuleMode FORWARD
Constant - the mode description for pure forward chaining


FORWARD_RETE

public static final GenericRuleReasoner.RuleMode FORWARD_RETE
Constant - the mode description for pure forward chaining, using RETE engine


BACKWARD

public static final GenericRuleReasoner.RuleMode BACKWARD
Constant - the mode description for pure backward chaining


HYBRID

public static final GenericRuleReasoner.RuleMode HYBRID
Constant - the mode description for mixed forward/backward, this is the default mode

Constructor Detail

GenericRuleReasoner

public GenericRuleReasoner(java.util.List<Rule> rules)
Constructor. This is the raw version that does not reference a ReasonerFactory and so has no capabilities description.

Parameters:
rules - a list of Rule instances which defines the ruleset to process

GenericRuleReasoner

public GenericRuleReasoner(ReasonerFactory factory,
                           Resource configuration)
Constructor

Parameters:
factory - the parent reasoner factory which is consulted to answer capability questions
configuration - RDF node to configure the rule set and mode, can be null

GenericRuleReasoner

public GenericRuleReasoner(java.util.List<Rule> rules,
                           ReasonerFactory factory)
Constructor

Parameters:
rules - a list of Rule instances which defines the ruleset to process
factory - the parent reasoner factory which is consulted to answer capability questions
Method Detail

setMode

public void setMode(GenericRuleReasoner.RuleMode mode)
Set the direction of rule inference desired. If set to a pure mode (FORWARD, BACKWARD) then the rules will be interpreted as operating in that direction which ever direction they were written in. In HYBRID mode then the direction of the rule itself which control whether it is used in forward or backward mode. In addition, HYBRID mode allows forward rules to generate addition backward rules.


setRules

public void setRules(java.util.List<Rule> rules)
Set (or change) the rule set that this reasoner should execute. This will not affect inference models already created from this reasoner.

Specified by:
setRules in interface RuleReasoner
Overrides:
setRules in class FBRuleReasoner
Parameters:
rules - a list of Rule objects

setOWLTranslation

public void setOWLTranslation(boolean enableOWLTranslation)
Set to true to enable translation of selected parts of an OWL schema to additional rules. At present only intersction statements are handled this way. The translation is only applicable in HYBRID mode.


setTransitiveClosureCaching

public void setTransitiveClosureCaching(boolean enableTGCCaching)
Set to true to enable caching of subclass/subproperty lattices in a specialized cache rather than using the rule systems. This has substantially higher performance but it is done as a separate initialization pass and so can only work correct with some rule sets. This is only guaranteed to be implemented for the HYBRID mode.


setFunctorFiltering

public void setFunctorFiltering(boolean param)
Set to true to cause functor-valued literals to be dropped from rule output. Default is true.


addPreprocessingHook

public void addPreprocessingHook(RulePreprocessHook hook)
Add a new preprocessing hook defining an operation that should be run when the inference graph is being prepared. This can be used to generate additional data-dependent rules or translations. This is only guaranted to be implemented for the HYBRID mode.


removePreprocessingHook

public void removePreprocessingHook(RulePreprocessHook hook)
Remove a preprocessing hook. defining an operation that


bindSchema

public Reasoner bindSchema(Graph tbox)
                    throws ReasonerException
Precompute the implications of a schema graph. The statements in the graph will be combined with the data when the final InfGraph is created.

Specified by:
bindSchema in interface Reasoner
Overrides:
bindSchema in class FBRuleReasoner
Parameters:
tbox - the ontology axioms or rule set encoded in RDF
Returns:
a reasoner instace which can be used to process a data graph
Throws:
ReasonerException - if the reasoner cannot be bound to a rule set in this way, for example if the underlying engine can only accept a single rule set in this way and one rule set has already been bound in of if the ruleset is illformed.

bind

public InfGraph bind(Graph data)
              throws ReasonerException
Attach the reasoner to a set of RDF data to process. The reasoner may already have been bound to specific rules or ontology axioms (encoded in RDF) through earlier bindRuleset calls.

Specified by:
bind in interface Reasoner
Overrides:
bind in class FBRuleReasoner
Parameters:
data - the RDF data to be processed, some reasoners may restrict the range of RDF which is legal here (e.g. syntactic restrictions in OWL).
Returns:
an inference graph through which the data+reasoner can be queried.
Throws:
ReasonerException - if the data is ill-formed according to the constraints imposed by this reasoner.


Copyright © 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Hewlett-Packard Development Company, LP