Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.hp.hpl.jena.reasoner.rulesys.impl.oldCode
Class BasicBackwardRuleInfGraph  view BasicBackwardRuleInfGraph download BasicBackwardRuleInfGraph.java

java.lang.Object
  extended bycom.hp.hpl.jena.graph.impl.GraphBase
      extended bycom.hp.hpl.jena.reasoner.BaseInfGraph
          extended bycom.hp.hpl.jena.reasoner.rulesys.impl.oldCode.BasicBackwardRuleInfGraph
All Implemented Interfaces:
com.hp.hpl.jena.reasoner.rulesys.BackwardRuleInfGraphI, com.hp.hpl.jena.graph.Graph, com.hp.hpl.jena.graph.GraphAdd, com.hp.hpl.jena.graph.impl.GraphWithPerform, com.hp.hpl.jena.reasoner.InfGraph, com.hp.hpl.jena.reasoner.rulesys.SilentAddI

public class BasicBackwardRuleInfGraph
extends com.hp.hpl.jena.reasoner.BaseInfGraph
implements com.hp.hpl.jena.reasoner.rulesys.BackwardRuleInfGraphI

An inference graph that runs a set of rules using a tabled backward chaining interpreter.

Version:
$Revision: 1.6 $ on $Date: 2005/02/21 12:18:03 $

Nested Class Summary
 
Nested classes inherited from class com.hp.hpl.jena.reasoner.BaseInfGraph
com.hp.hpl.jena.reasoner.BaseInfGraph.InfCapabilities, com.hp.hpl.jena.reasoner.BaseInfGraph.InfFindSafeCapabilities, com.hp.hpl.jena.reasoner.BaseInfGraph.InfTransactionHandler
 
Field Summary
protected  com.hp.hpl.jena.reasoner.rulesys.impl.BBRuleContext context
          Single context for the reasoner, used when passing information to builtins
protected  com.hp.hpl.jena.reasoner.Finder dataFind
          A finder that searches across the data, schema and axioms
static long DEFAULT_RULES_THRESHOLD
          Default setting for rules threshold
protected  com.hp.hpl.jena.util.OneToManyMap derivations
          Table of derivation records, maps from triple to RuleDerivation
protected  BRuleEngine engine
          The core rule engine which includes all the memoized results
protected  com.hp.hpl.jena.reasoner.FGraph fdeductions
          Cache of deductions made from the rules
protected  com.hp.hpl.jena.reasoner.FGraph fschema
          An optional graph of separate schema assertions that should also be processed
(package private) static org.apache.commons.logging.Log logger
           
(package private)  long nRulesFired
          performance stats - number of rules fired
(package private)  long nRulesThreshold
          threshold on the numbers of rule firings allowed in a single operation
(package private)  int nRulesTriggered
          performance stats - number of rules passing initial trigger
protected  java.util.List rules
          Set for rules being used
protected  com.hp.hpl.jena.reasoner.rulesys.impl.TempNodeCache tempNodecache
          Cache of temporary property values inferred through getTemp calls
(package private)  boolean traceOn
          Flag which, if true, enables tracing of rule actions to logger.info
 
Fields inherited from class com.hp.hpl.jena.reasoner.BaseInfGraph
fdata, isPrepared, reasoner, recordDerivations
 
Fields inherited from class com.hp.hpl.jena.graph.impl.GraphBase
bulkHandler, capabilities, closed, gem, pm, queryHandler, reifier, style
 
Fields inherited from interface com.hp.hpl.jena.graph.Graph
emptyGraph
 
Constructor Summary
BasicBackwardRuleInfGraph(com.hp.hpl.jena.reasoner.Reasoner reasoner, com.hp.hpl.jena.reasoner.rulesys.impl.RuleStore ruleStore, com.hp.hpl.jena.graph.Graph data, com.hp.hpl.jena.graph.Graph schema)
          Constructor.
 
Method Summary
 void dump()
          Dump an a summary of the goal table state to stdout.
protected  void extractAxioms()
          Find any axioms (rules with no body) in the rule set and add those to the auxilliary graph to be included in searches.
 com.hp.hpl.jena.util.iterator.ExtendedIterator find(com.hp.hpl.jena.reasoner.TriplePattern pattern)
          Basic pattern lookup interface.
 com.hp.hpl.jena.util.iterator.ExtendedIterator findDataMatches(com.hp.hpl.jena.reasoner.TriplePattern pattern)
          Match a pattern just against the stored data (raw data, schema, axioms) but no derivation.
 com.hp.hpl.jena.util.iterator.ExtendedIterator findWithContinuation(com.hp.hpl.jena.reasoner.TriplePattern pattern, com.hp.hpl.jena.reasoner.Finder continuation)
          Extended find interface used in situations where the implementator may or may not be able to answer the complete query.
 java.util.Iterator getDerivation(com.hp.hpl.jena.graph.Triple t)
          Return the derivation of at triple.
 com.hp.hpl.jena.graph.Graph getSchemaGraph()
          Return the schema graph, if any, bound into this inference graph.
 com.hp.hpl.jena.graph.Node getTemp(com.hp.hpl.jena.graph.Node instance, com.hp.hpl.jena.graph.Node prop, com.hp.hpl.jena.graph.Node pclass)
          Retrieve or create a bNode representing an inferred property value.
 com.hp.hpl.jena.util.iterator.ExtendedIterator graphBaseFind(com.hp.hpl.jena.graph.Node subject, com.hp.hpl.jena.graph.Node property, com.hp.hpl.jena.graph.Node object)
          Returns an iterator over Triples.
 boolean isTraceOn()
          Return true if tracing is switched on
 void logDerivation(com.hp.hpl.jena.graph.Triple t, java.lang.Object derivation)
          Log a dervivation record against the given triple.
 void performAdd(com.hp.hpl.jena.graph.Triple t)
          Add one triple to the data graph, run any rules triggered by the new data item, recursively adding any generated triples.
 void performDelete(com.hp.hpl.jena.graph.Triple t)
          Removes the triple t (if possible) from the set belonging to this graph.
 void prepare()
          Perform any initial processing and caching.
 boolean processBuiltin(com.hp.hpl.jena.reasoner.rulesys.ClauseEntry clause, com.hp.hpl.jena.reasoner.rulesys.Rule rule, com.hp.hpl.jena.reasoner.rulesys.BindingEnvironment env)
          Process a call to a builtin predicate
 void rebind()
          Cause the inference graph to reconsult the underlying graph to take into account changes.
 void rebind(com.hp.hpl.jena.graph.Graph data)
          Replace the underlying data graph for this inference graph and start any inferences over again.
 void reset()
          Flush out all cached results.
 void setDerivationLogging(boolean recordDerivations)
          Set to true to enable derivation caching
 void setRuleThreshold(long threshold)
          Change the threshold on the number of rule firings allowed during a single operation.
 void setTraceOn(boolean state)
          Set the state of the trace flag.
 void silentAdd(com.hp.hpl.jena.graph.Triple t)
          Assert a new triple in the deduction graph, bypassing any processing machinery.
 
Methods inherited from class com.hp.hpl.jena.reasoner.BaseInfGraph
cloneWithPremises, close, discardState, find, getBulkUpdateHandler, getCapabilities, getDeductionsGraph, getGlobalProperty, getPrefixMapping, getRawGraph, getReasoner, getReifier, getTransactionHandler, graphBaseFind, graphBaseSize, isEmpty, testGlobalProperty, validate
 
Methods inherited from class com.hp.hpl.jena.graph.impl.GraphBase
add, checkOpen, contains, contains, containsByFind, delete, dependsOn, find, find, getEventManager, graphBaseContains, isIsomorphicWith, notifyAdd, notifyDelete, queryHandler, reifierContains, reifierSize, reifierTriples, size, toString, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.hp.hpl.jena.reasoner.InfGraph
find, getDeductionsGraph, getGlobalProperty, getRawGraph, getReasoner, testGlobalProperty, validate
 
Methods inherited from interface com.hp.hpl.jena.graph.Graph
close, contains, contains, delete, dependsOn, find, find, getBulkUpdateHandler, getCapabilities, getEventManager, getPrefixMapping, getReifier, getTransactionHandler, isEmpty, isIsomorphicWith, queryHandler, size
 
Methods inherited from interface com.hp.hpl.jena.graph.GraphAdd
add
 

Field Detail

rules

protected java.util.List rules
Set for rules being used


derivations

protected com.hp.hpl.jena.util.OneToManyMap derivations
Table of derivation records, maps from triple to RuleDerivation


fschema

protected com.hp.hpl.jena.reasoner.FGraph fschema
An optional graph of separate schema assertions that should also be processed


fdeductions

protected com.hp.hpl.jena.reasoner.FGraph fdeductions
Cache of deductions made from the rules


dataFind

protected com.hp.hpl.jena.reasoner.Finder dataFind
A finder that searches across the data, schema and axioms


engine

protected BRuleEngine engine
The core rule engine which includes all the memoized results


context

protected com.hp.hpl.jena.reasoner.rulesys.impl.BBRuleContext context
Single context for the reasoner, used when passing information to builtins


tempNodecache

protected com.hp.hpl.jena.reasoner.rulesys.impl.TempNodeCache tempNodecache
Cache of temporary property values inferred through getTemp calls


nRulesTriggered

int nRulesTriggered
performance stats - number of rules passing initial trigger


nRulesFired

long nRulesFired
performance stats - number of rules fired


nRulesThreshold

long nRulesThreshold
threshold on the numbers of rule firings allowed in a single operation


traceOn

boolean traceOn
Flag which, if true, enables tracing of rule actions to logger.info


DEFAULT_RULES_THRESHOLD

public static final long DEFAULT_RULES_THRESHOLD
Default setting for rules threshold

See Also:
Constant Field Values

logger

static org.apache.commons.logging.Log logger
Constructor Detail

BasicBackwardRuleInfGraph

public BasicBackwardRuleInfGraph(com.hp.hpl.jena.reasoner.Reasoner reasoner,
                                 com.hp.hpl.jena.reasoner.rulesys.impl.RuleStore ruleStore,
                                 com.hp.hpl.jena.graph.Graph data,
                                 com.hp.hpl.jena.graph.Graph schema)
Constructor. Create a new backward inference graph to process the given data. The parent reasoner supplies the ruleset and any additional schema graph.

Method Detail

getSchemaGraph

public com.hp.hpl.jena.graph.Graph getSchemaGraph()
Return the schema graph, if any, bound into this inference graph.


prepare

public void prepare()
Perform any initial processing and caching. This call is optional. Most engines either have negligable set up work or will perform an implicit "prepare" if necessary. The call is provided for those occasions where substantial preparation work is possible (e.g. running a forward chaining rule system) and where an application might wish greater control over when this prepration is done.

Specified by:
prepare in interface com.hp.hpl.jena.reasoner.InfGraph

rebind

public void rebind(com.hp.hpl.jena.graph.Graph data)
Replace the underlying data graph for this inference graph and start any inferences over again. This is primarily using in setting up ontology imports processing to allow an imports multiunion graph to be inserted between the inference graph and the raw data, before processing.

Specified by:
rebind in interface com.hp.hpl.jena.reasoner.InfGraph

rebind

public void rebind()
Cause the inference graph to reconsult the underlying graph to take into account changes. Normally changes are made through the InfGraph's add and remove calls are will be handled appropriately. However, in some cases changes are made "behind the InfGraph's back" and this forces a full reconsult of the changed data.

Specified by:
rebind in interface com.hp.hpl.jena.reasoner.InfGraph

findWithContinuation

public com.hp.hpl.jena.util.iterator.ExtendedIterator findWithContinuation(com.hp.hpl.jena.reasoner.TriplePattern pattern,
                                                                           com.hp.hpl.jena.reasoner.Finder continuation)
Extended find interface used in situations where the implementator may or may not be able to answer the complete query. It will attempt to answer the pattern but if its answers are not known to be complete then it will also pass the request on to the nested Finder to append more results.


graphBaseFind

public com.hp.hpl.jena.util.iterator.ExtendedIterator graphBaseFind(com.hp.hpl.jena.graph.Node subject,
                                                                    com.hp.hpl.jena.graph.Node property,
                                                                    com.hp.hpl.jena.graph.Node object)
Returns an iterator over Triples. This implementation assumes that the underlying findWithContinuation will have also consulted the raw data.


find

public com.hp.hpl.jena.util.iterator.ExtendedIterator find(com.hp.hpl.jena.reasoner.TriplePattern pattern)
Basic pattern lookup interface. This implementation assumes that the underlying findWithContinuation will have also consulted the raw data.


reset

public void reset()
Flush out all cached results. Future queries have to start from scratch.

Specified by:
reset in interface com.hp.hpl.jena.reasoner.InfGraph

performAdd

public void performAdd(com.hp.hpl.jena.graph.Triple t)
Add one triple to the data graph, run any rules triggered by the new data item, recursively adding any generated triples.

Specified by:
performAdd in interface com.hp.hpl.jena.graph.impl.GraphWithPerform

performDelete

public void performDelete(com.hp.hpl.jena.graph.Triple t)
Removes the triple t (if possible) from the set belonging to this graph.

Specified by:
performDelete in interface com.hp.hpl.jena.graph.impl.GraphWithPerform

setDerivationLogging

public void setDerivationLogging(boolean recordDerivations)
Set to true to enable derivation caching

Specified by:
setDerivationLogging in interface com.hp.hpl.jena.reasoner.InfGraph

getDerivation

public java.util.Iterator getDerivation(com.hp.hpl.jena.graph.Triple t)
Return the derivation of at triple. The derivation is a List of DerivationRecords

Specified by:
getDerivation in interface com.hp.hpl.jena.reasoner.InfGraph

setRuleThreshold

public void setRuleThreshold(long threshold)
Change the threshold on the number of rule firings allowed during a single operation.


setTraceOn

public void setTraceOn(boolean state)
Set the state of the trace flag. If set to true then rule firings are logged out to the Log at "INFO" level.


isTraceOn

public boolean isTraceOn()
Return true if tracing is switched on


dump

public void dump()
Dump an a summary of the goal table state to stdout. Just debugging, do not use for real.


logDerivation

public void logDerivation(com.hp.hpl.jena.graph.Triple t,
                          java.lang.Object derivation)
Log a dervivation record against the given triple.

Specified by:
logDerivation in interface com.hp.hpl.jena.reasoner.rulesys.BackwardRuleInfGraphI

findDataMatches

public com.hp.hpl.jena.util.iterator.ExtendedIterator findDataMatches(com.hp.hpl.jena.reasoner.TriplePattern pattern)
Match a pattern just against the stored data (raw data, schema, axioms) but no derivation.

Specified by:
findDataMatches in interface com.hp.hpl.jena.reasoner.rulesys.BackwardRuleInfGraphI

processBuiltin

public boolean processBuiltin(com.hp.hpl.jena.reasoner.rulesys.ClauseEntry clause,
                              com.hp.hpl.jena.reasoner.rulesys.Rule rule,
                              com.hp.hpl.jena.reasoner.rulesys.BindingEnvironment env)
Process a call to a builtin predicate

Specified by:
processBuiltin in interface com.hp.hpl.jena.reasoner.rulesys.BackwardRuleInfGraphI

silentAdd

public void silentAdd(com.hp.hpl.jena.graph.Triple t)
Assert a new triple in the deduction graph, bypassing any processing machinery.

Specified by:
silentAdd in interface com.hp.hpl.jena.reasoner.rulesys.SilentAddI

getTemp

public com.hp.hpl.jena.graph.Node getTemp(com.hp.hpl.jena.graph.Node instance,
                                          com.hp.hpl.jena.graph.Node prop,
                                          com.hp.hpl.jena.graph.Node pclass)
Retrieve or create a bNode representing an inferred property value.

Specified by:
getTemp in interface com.hp.hpl.jena.reasoner.rulesys.BackwardRuleInfGraphI

extractAxioms

protected void extractAxioms()
Find any axioms (rules with no body) in the rule set and add those to the auxilliary graph to be included in searches.