| com.hp.hpl.jena.reasoner.BaseInfGraph com.hp.hpl.jena.reasoner.rulesys.BasicForwardRuleInfGraph
All known Subclasses: com.hp.hpl.jena.reasoner.rulesys.FBRuleInfGraph, com.hp.hpl.jena.reasoner.rulesys.impl.oldCode.OrigFBRuleInfGraph, com.hp.hpl.jena.reasoner.rulesys.RETERuleInfGraph,
BasicForwardRuleInfGraph | public class BasicForwardRuleInfGraph extends BaseInfGraph implements ForwardRuleInfGraphI(Code) | | An inference graph interface that runs a set of forward chaining
rules to conclusion on each added triple and stores the entire
result set.
This implementation has a horribly inefficient rule chainer built in.
Once we have this working generalize this to an interface than
can call out to a rule engine and build a real rule engine (e.g. Rete style).
author: Dave Reynolds version: $Revision: 1.50 $ on $Date: 2008/01/02 12:07:47 $ |
Method Summary | |
public void | addBRule(Rule brule) Adds a new Backward rule as a rules of a forward rule process. | public void | addDeduction(Triple t) Add a new deduction to the deductions graph. | public void | close() Free all resources, any further use of this Graph is an error. | public Reifier | constructReifier() | protected Graph | createDeductionsGraph() Create the graph used to hold the deductions. | public void | deleteBRule(Rule brule) Deletes a new Backward rule as a rules of a forward rule process. | public ExtendedIterator | find(TriplePattern pattern) Basic pattern lookup interface. | public ExtendedIterator | findDataMatches(Node subject, Node predicate, Node object) Search the combination of data and deductions graphs for the given triple pattern. | public ExtendedIterator | findWithContinuation(TriplePattern pattern, Finder continuation) Extended find interface used in situations where the implementator
may or may not be able to answer the complete query. | public Graph | getCurrentDeductionsGraph() Return the Graph containing all the static deductions available so far. | public Graph | getDeductionsGraph() Return the Graph containing all the static deductions available so far. | public Iterator | getDerivation(Triple t) Return the derivation of at triple. | public long | getNRulesFired() | public Graph | getSchemaGraph() Return the schema graph, if any, bound into this inference graph. | public ExtendedIterator | graphBaseFind(Node subject, Node property, Node object) Returns an iterator over Triples. | public int | graphBaseSize() | protected void | instantiateRuleEngine(List rules) Instantiate the forward rule engine to use. | public void | logDerivation(Triple t, Object derivation) Log a dervivation record against the given triple. | public synchronized void | performAdd(Triple t) Add one triple to the data graph, run any rules triggered by
the new data item, recursively adding any generated triples. | public void | performDelete(Triple t) Removes the triple t (if possible) from the set belonging to this graph. | protected boolean | preloadDeductions(Graph preloadIn) Adds a set of precomputed triples to the deductions store. | public synchronized void | prepare() Perform any initial processing and caching. | public void | rebind(Graph data) Replace the underlying data graph for this inference graph and start any
inferences over again. | public void | rebind() Cause the inference graph to reconsult the underlying graph to take
into account changes. | public void | setDerivationLogging(boolean recordDerivations) | public void | setRuleStore(Object ruleStore) Attach a compiled rule set to this inference graph.
Parameters: ruleStore - a compiled set of rules (i.e. | public void | setTraceOn(boolean state) Set the state of the trace flag. | public boolean | shouldLogDerivations() Return true if derivation logging is enabled. | public boolean | shouldTrace() Return true if tracing should be acted on - i.e. | public void | silentAdd(Triple t) Assert a new triple in the deduction graph, bypassing any processing machinery. |
derivations | protected OneToManyMap derivations(Code) | | Table of derivation records, maps from triple to RuleDerivation
|
fdeductions | protected FGraph fdeductions(Code) | | The set of deduced triples, this is in addition to base triples in the fdata graph
|
logger | protected static Log logger(Code) | | |
rules | protected List rules(Code) | | The original rule set as supplied
|
schemaGraph | protected Graph schemaGraph(Code) | | Reference to any schema graph data bound into the parent reasoner
|
traceOn | protected boolean traceOn(Code) | | Flag which, if true, enables tracing of rule actions to logger.info
|
BasicForwardRuleInfGraph | public BasicForwardRuleInfGraph(Reasoner reasoner, Graph schema)(Code) | | Constructor. Creates a new inference graph to which a (compiled) rule set
and a data graph can be attached. This separation of binding is useful to allow
any configuration parameters (such as logging) to be set before the data is added.
Note that until the data is added using
BasicForwardRuleInfGraph.rebind rebind then any operations
like add, remove, find will result in errors.
Parameters: reasoner - the parent reasoner Parameters: schema - the (optional) schema data which is being processed |
BasicForwardRuleInfGraph | public BasicForwardRuleInfGraph(Reasoner reasoner, List rules, Graph schema)(Code) | | Constructor. Creates a new inference graph based on the given rule set.
No data graph is attached at this stage. This is to allow
any configuration parameters (such as logging) to be set before the data is added.
Note that until the data is added using
BasicForwardRuleInfGraph.rebind rebind then any operations
like add, remove, find will result in errors.
Parameters: reasoner - the parent reasoner Parameters: rules - the list of rules to use this time Parameters: schema - the (optional) schema or preload data which is being processed |
BasicForwardRuleInfGraph | public BasicForwardRuleInfGraph(Reasoner reasoner, List rules, Graph schema, Graph data)(Code) | | Constructor. Creates a new inference graph based on the given rule set
then processes the initial data graph. No precomputed deductions are loaded.
Parameters: reasoner - the parent reasoner Parameters: rules - the list of rules to use this time Parameters: schema - the (optional) schema or preload data which is being processed Parameters: data - the data graph to be processed |
addBRule | public void addBRule(Rule brule)(Code) | | Adds a new Backward rule as a rules of a forward rule process. Only some
infgraphs support this.
|
addDeduction | public void addDeduction(Triple t)(Code) | | Add a new deduction to the deductions graph.
|
close | public void close()(Code) | | Free all resources, any further use of this Graph is an error.
|
createDeductionsGraph | protected Graph createDeductionsGraph()(Code) | | Create the graph used to hold the deductions. Can be overridden
by subclasses that need special purpose graph implementations here.
Assumes the graph underlying fdeductions can be reused if present.
|
deleteBRule | public void deleteBRule(Rule brule)(Code) | | Deletes a new Backward rule as a rules of a forward rule process. Only some
infgraphs support this.
|
find | public ExtendedIterator find(TriplePattern pattern)(Code) | | Basic pattern lookup interface.
This implementation assumes that the underlying findWithContinuation
will have also consulted the raw data.
Parameters: pattern - a TriplePattern to be matched against the data a ExtendedIterator over all Triples in the data setthat match the pattern |
findDataMatches | public ExtendedIterator findDataMatches(Node subject, Node predicate, Node object)(Code) | | Search the combination of data and deductions graphs for the given triple pattern.
This may different from the normal find operation in the base of hybrid reasoners
where we are side-stepping the backward deduction step.
|
findWithContinuation | public ExtendedIterator findWithContinuation(TriplePattern pattern, Finder continuation)(Code) | | 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.
Parameters: pattern - a TriplePattern to be matched against the data Parameters: continuation - either a Finder or a normal Graph whichwill be asked for additional match results if the implementormay not have completely satisfied the query. |
getCurrentDeductionsGraph | public Graph getCurrentDeductionsGraph()(Code) | | Return the Graph containing all the static deductions available so far.
Does not trigger a prepare action.
|
getDeductionsGraph | public Graph getDeductionsGraph()(Code) | | Return the Graph containing all the static deductions available so far.
|
getDerivation | public Iterator getDerivation(Triple t)(Code) | | Return the derivation of at triple.
The derivation is a List of DerivationRecords
|
getNRulesFired | public long getNRulesFired()(Code) | | Return the number of rules fired since this rule engine instance
was created and initialized
|
getSchemaGraph | public Graph getSchemaGraph()(Code) | | Return the schema graph, if any, bound into this inference graph.
|
graphBaseFind | public ExtendedIterator graphBaseFind(Node subject, Node property, Node object)(Code) | | Returns an iterator over Triples.
This implementation assumes that the underlying findWithContinuation
will have also consulted the raw data.
|
graphBaseSize | public int graphBaseSize()(Code) | | Return the number of triples in the inferred graph
|
instantiateRuleEngine | protected void instantiateRuleEngine(List rules)(Code) | | Instantiate the forward rule engine to use.
Subclasses can override this to switch to, say, a RETE imlementation.
Parameters: rules - the rule set or null if there are not rules bound in yet. |
logDerivation | public void logDerivation(Triple t, Object derivation)(Code) | | Log a dervivation record against the given triple.
|
performAdd | public synchronized void performAdd(Triple t)(Code) | | Add one triple to the data graph, run any rules triggered by
the new data item, recursively adding any generated triples.
|
performDelete | public void performDelete(Triple t)(Code) | | Removes the triple t (if possible) from the set belonging to this graph.
|
preloadDeductions | protected boolean preloadDeductions(Graph preloadIn)(Code) | | Adds a set of precomputed triples to the deductions store. These do not, themselves,
fire any rules but provide additional axioms that might enable future rule
firing when real data is added. Used to implement bindSchema processing
in the parent Reasoner.
return true if the rule set has also been loaded |
prepare | public synchronized void prepare()(Code) | | 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.
|
rebind | public void rebind(Graph data)(Code) | | 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.
Parameters: data - the new raw data graph |
rebind | public void rebind()(Code) | | 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.
|
setDerivationLogging | public void setDerivationLogging(boolean recordDerivations)(Code) | | Set to true to enable derivation caching
|
setRuleStore | public void setRuleStore(Object ruleStore)(Code) | | Attach a compiled rule set to this inference graph.
Parameters: ruleStore - a compiled set of rules (i.e. the result of an FRuleEngine.compile). |
setTraceOn | public void setTraceOn(boolean state)(Code) | | Set the state of the trace flag. If set to true then rule firings
are logged out to the Log at "INFO" level.
|
shouldLogDerivations | public boolean shouldLogDerivations()(Code) | | Return true if derivation logging is enabled.
|
shouldTrace | public boolean shouldTrace()(Code) | | Return true if tracing should be acted on - i.e. if traceOn is true
and we are past the bootstrap phase.
|
silentAdd | public void silentAdd(Triple t)(Code) | | Assert a new triple in the deduction graph, bypassing any processing machinery.
|
|
|