public class BasicForwardRuleInfGraph extends BaseInfGraph implements ForwardRuleInfGraphI
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).
BaseInfGraph.InfCapabilities, BaseInfGraph.InfFindSafeCapabilities, BaseInfGraph.InfTransactionHandler
Modifier and Type | Field and Description |
---|---|
boolean |
filterFunctors
Flag, if true then find results will be filtered to remove functors and illegal RDF
|
TOSTRING_TRIPLE_BASE, TOSTRING_TRIPLE_LIMIT
emptyGraph
Constructor and Description |
---|
BasicForwardRuleInfGraph(Reasoner reasoner,
Graph schema)
Constructor.
|
BasicForwardRuleInfGraph(Reasoner reasoner,
List<Rule> rules,
Graph schema)
Constructor.
|
BasicForwardRuleInfGraph(Reasoner reasoner,
List<Rule> rules,
Graph schema,
Graph data)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addBRule(Rule brule)
Adds a new Backward rule as a rules of a forward rule process.
|
void |
addDeduction(Triple t)
Add a new deduction to the deductions graph.
|
void |
close()
Free all resources, any further use of this Graph is an error.
|
void |
deleteBRule(Rule brule)
Deletes a new Backward rule as a rules of a forward rule process.
|
ExtendedIterator<Triple> |
find(TriplePattern pattern)
Basic pattern lookup interface.
|
ExtendedIterator<Triple> |
findDataMatches(Node subject,
Node predicate,
Node object)
Search the combination of data and deductions graphs for the given triple pattern.
|
ExtendedIterator<Triple> |
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.
|
Graph |
getCurrentDeductionsGraph()
Return the Graph containing all the static deductions available so far.
|
Graph |
getDeductionsGraph()
Return the Graph containing all the static deductions available so far.
|
Iterator<Derivation> |
getDerivation(Triple t)
Return the derivation of at triple.
|
long |
getNRulesFired()
Return the number of rules fired since this rule engine instance
was created and initialized
|
Graph |
getSchemaGraph()
Return the schema graph, if any, bound into this inference graph.
|
int |
graphBaseSize()
Return the number of triples in the inferred graph
|
void |
logDerivation(Triple t,
Derivation derivation)
Log a dervivation record against the given triple.
|
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.
|
void |
performDelete(Triple t)
Removes the triple t (if possible) from the set belonging to this graph.
|
void |
prepare()
Perform any initial processing and caching.
|
void |
rebind()
Cause the inference graph to reconsult the underlying graph to take
into account changes.
|
void |
rebind(Graph data)
Replace the underlying data graph for this inference graph and start any
inferences over again.
|
void |
setDerivationLogging(boolean recordDerivations)
Set to true to enable derivation caching
|
void |
setFunctorFiltering(boolean param)
Set to true to cause functor-valued literals to be dropped from rule output.
|
void |
setRuleStore(Object ruleStore)
Attach a compiled rule set to this inference graph.
|
void |
setTraceOn(boolean state)
Set the state of the trace flag.
|
boolean |
shouldLogDerivations()
Return true if derivation logging is enabled.
|
boolean |
shouldTrace()
Return true if tracing should be acted on - i.e.
|
void |
silentAdd(Triple t)
Assert a new triple in the deduction graph, bypassing any processing machinery.
|
clear, cloneWithPremises, find, getCapabilities, getGlobalProperty, getPrefixMapping, getRawGraph, getReasoner, getTransactionHandler, getVersion, isEmpty, isPrepared, remove, reset, testGlobalProperty, validate
add, contains, contains, delete, dependsOn, find, find, forTestingOnly_graphBaseFind, getEventManager, getStatisticsHandler, isClosed, isIsomorphicWith, notifyAdd, notifyDelete, size, toString, toString
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
find, getGlobalProperty, getRawGraph, getReasoner, reset, testGlobalProperty, validate
add, clear, contains, contains, delete, dependsOn, find, find, find, getCapabilities, getEventManager, getPrefixMapping, getStatisticsHandler, getTransactionHandler, isClosed, isEmpty, isIsomorphicWith, remove, size
public boolean filterFunctors
public BasicForwardRuleInfGraph(Reasoner reasoner, Graph schema)
rebind
then any operations
like add, remove, find will result in errors.reasoner
- the parent reasonerschema
- the (optional) schema data which is being processedpublic BasicForwardRuleInfGraph(Reasoner reasoner, List<Rule> rules, Graph schema)
rebind
then any operations
like add, remove, find will result in errors.reasoner
- the parent reasonerrules
- the list of rules to use this timeschema
- the (optional) schema or preload data which is being processedpublic BasicForwardRuleInfGraph(Reasoner reasoner, List<Rule> rules, Graph schema, Graph data)
reasoner
- the parent reasonerrules
- the list of rules to use this timeschema
- the (optional) schema or preload data which is being processeddata
- the data graph to be processedpublic void setRuleStore(Object ruleStore)
ruleStore
- a compiled set of rules (i.e. the result of an FRuleEngine.compile).public void rebind(Graph data)
rebind
in interface InfGraph
rebind
in class BaseInfGraph
data
- the new raw data graphpublic void rebind()
rebind
in interface InfGraph
rebind
in class BaseInfGraph
public Graph getSchemaGraph()
getSchemaGraph
in class BaseInfGraph
public void prepare()
prepare
in interface InfGraph
prepare
in class BaseInfGraph
public void addDeduction(Triple t)
addDeduction
in interface ForwardRuleInfGraphI
public void setFunctorFiltering(boolean param)
setFunctorFiltering
in interface ForwardRuleInfGraphI
public ExtendedIterator<Triple> findWithContinuation(TriplePattern pattern, Finder continuation)
findWithContinuation
in class BaseInfGraph
pattern
- a TriplePattern to be matched against the datacontinuation
- either a Finder or a normal Graph which
will be asked for additional match results if the implementor
may not have completely satisfied the query.public ExtendedIterator<Triple> find(TriplePattern pattern)
find
in class BaseInfGraph
pattern
- a TriplePattern to be matched against the datapublic void performAdd(Triple t)
performAdd
in interface GraphWithPerform
performAdd
in class BaseInfGraph
public int graphBaseSize()
graphBaseSize
in class BaseInfGraph
public void performDelete(Triple t)
performDelete
in interface GraphWithPerform
performDelete
in class BaseInfGraph
public void close()
close
in interface Graph
close
in class BaseInfGraph
public void addBRule(Rule brule)
addBRule
in interface ForwardRuleInfGraphI
public void deleteBRule(Rule brule)
deleteBRule
in interface ForwardRuleInfGraphI
public Graph getDeductionsGraph()
getDeductionsGraph
in interface InfGraph
getDeductionsGraph
in interface ForwardRuleInfGraphI
getDeductionsGraph
in class BaseInfGraph
public Graph getCurrentDeductionsGraph()
getCurrentDeductionsGraph
in interface ForwardRuleInfGraphI
public ExtendedIterator<Triple> findDataMatches(Node subject, Node predicate, Node object)
findDataMatches
in interface ForwardRuleInfGraphI
public void logDerivation(Triple t, Derivation derivation)
logDerivation
in interface ForwardRuleInfGraphI
public void silentAdd(Triple t)
silentAdd
in interface SilentAddI
public void setDerivationLogging(boolean recordDerivations)
setDerivationLogging
in interface InfGraph
setDerivationLogging
in class BaseInfGraph
public boolean shouldLogDerivations()
shouldLogDerivations
in interface ForwardRuleInfGraphI
public Iterator<Derivation> getDerivation(Triple t)
getDerivation
in interface InfGraph
getDerivation
in class BaseInfGraph
public void setTraceOn(boolean state)
public boolean shouldTrace()
shouldTrace
in interface ForwardRuleInfGraphI
public long getNRulesFired()
Licenced under the Apache License, Version 2.0