java.lang.Object
org.apache.jena.graph.impl.GraphBase
org.apache.jena.reasoner.BaseInfGraph
org.apache.jena.reasoner.rulesys.LPBackwardRuleInfGraph
- All Implemented Interfaces:
Graph,GraphWithPerform,InfGraph,BackwardRuleInfGraphI,SilentAddI
Inference graph for accessing the LP version of the backward chaining
rule engine.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.jena.reasoner.BaseInfGraph
BaseInfGraph.InfTransactionHandler -
Field Summary
Fields inherited from class org.apache.jena.reasoner.BaseInfGraph
reasonerInfCapabilitiesFields inherited from class org.apache.jena.graph.impl.GraphBase
TOSTRING_TRIPLE_BASE, TOSTRING_TRIPLE_LIMITFields inherited from interface org.apache.jena.graph.Graph
emptyGraph -
Constructor Summary
ConstructorsConstructorDescriptionLPBackwardRuleInfGraph(Reasoner reasoner, LPRuleStore ruleStore, Graph data, Graph schema) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionfind(TriplePattern pattern) Basic pattern lookup interface.findDataMatches(TriplePattern pattern) Match a pattern just against the stored data (raw data, schema, axioms) but no derivation.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.Return the derivation of at triple.Return the schema graph, if any, bound into this inference graph.Retrieve or create a bNode representing an inferred property value.graphBaseFind(Node subject, Node property, Node object) Returns an iterator over Triples.booleanReturn true if tracing is switched onvoidlogDerivation(Triple t, Derivation derivation) Log a derivation record against the given triple.voidperformAdd(Triple t) Add one triple to the data graph, run any rules triggered by the new data item, recursively adding any generated triples.voidRemoves the triple t (if possible) from the set belonging to this graph.voidprepare()Perform any initial processing and caching.booleanprocessBuiltin(ClauseEntry clause, Rule rule, BindingEnvironment env) Process a call to a builtin predicatevoidrebind()Cause the inference graph to reconsult the underlying graph to take into account changes.voidReplace the underlying data graph for this inference graph and start any inferences over again.voidreset()Flush out all cached results.voidsetDerivationLogging(boolean recordDerivations) Set to true to enable derivation cachingvoidSet a predicate to be tabled/memoized by the LP engine.voidsetTraceOn(boolean state) Set the state of the trace flag.voidAssert a new triple in the deduction graph, bypassing any processing machinery.Methods inherited from class org.apache.jena.reasoner.BaseInfGraph
clear, cloneWithPremises, close, find, getCapabilities, getDeductionsGraph, getGlobalProperty, getPrefixMapping, getRawGraph, getReasoner, getTransactionHandler, getVersion, graphBaseSize, isEmpty, isPrepared, remove, testGlobalProperty, validateMethods inherited from class org.apache.jena.graph.impl.GraphBase
add, contains, contains, delete, dependsOn, find, find, forTestingOnly_graphBaseFind, getEventManager, isClosed, isIsomorphicWith, notifyAdd, notifyDelete, size, toString, toStringMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.jena.reasoner.rulesys.BackwardRuleInfGraphI
getVersionMethods inherited from interface org.apache.jena.graph.Graph
add, add, clear, close, contains, contains, delete, delete, dependsOn, find, find, find, getCapabilities, getEventManager, getPrefixMapping, getTransactionHandler, isClosed, isEmpty, isIsomorphicWith, remove, size, sizeLong, stream, streamMethods inherited from interface org.apache.jena.reasoner.InfGraph
find, getDeductionsGraph, getGlobalProperty, getRawGraph, getReasoner, testGlobalProperty, validate
-
Constructor Details
-
LPBackwardRuleInfGraph
Constructor. Create a new backward inference graph to process the given data. The parent reasoner supplies the ruleset and any additional schema graph.- Parameters:
reasoner- the parent reasonerruleStore- the indexed set of rules to usedata- the data graph to be processedschema- optional precached schema (use null if not required)
-
-
Method Details
-
getSchemaGraph
Return the schema graph, if any, bound into this inference graph.- Specified by:
getSchemaGraphin classBaseInfGraph
-
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 preparation is done.- Specified by:
preparein interfaceInfGraph- Overrides:
preparein classBaseInfGraph
-
rebind
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:
rebindin interfaceInfGraph- Overrides:
rebindin classBaseInfGraph- Parameters:
data- the new raw data graph
-
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:
rebindin interfaceInfGraph- Overrides:
rebindin classBaseInfGraph
-
reset
public void reset()Flush out all cached results. Future queries have to start from scratch.- Specified by:
resetin interfaceInfGraph- Overrides:
resetin classBaseInfGraph
-
findWithContinuation
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.- Specified by:
findWithContinuationin classBaseInfGraph- Parameters:
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.
-
graphBaseFind
Returns an iterator over Triples. This implementation assumes that the underlying findWithContinuation will have also consulted the raw data. -
find
Basic pattern lookup interface. This implementation assumes that the underlying findWithContinuation will have also consulted the raw data.- Overrides:
findin classBaseInfGraph- Parameters:
pattern- a TriplePattern to be matched against the data- Returns:
- a ExtendedIterator over all Triples in the data set that match the pattern
-
performAdd
Add one triple to the data graph, run any rules triggered by the new data item, recursively adding any generated triples.- Specified by:
performAddin interfaceGraphWithPerform- Overrides:
performAddin classBaseInfGraph
-
performDelete
Removes the triple t (if possible) from the set belonging to this graph.- Specified by:
performDeletein interfaceGraphWithPerform- Overrides:
performDeletein classBaseInfGraph
-
setTabled
Set a predicate to be tabled/memoized by the LP engine. -
setDerivationLogging
public void setDerivationLogging(boolean recordDerivations) Set to true to enable derivation caching- Specified by:
setDerivationLoggingin interfaceInfGraph- Overrides:
setDerivationLoggingin classBaseInfGraph
-
getDerivation
Return the derivation of at triple. The derivation is a List of DerivationRecords- Specified by:
getDerivationin interfaceInfGraph- Overrides:
getDerivationin classBaseInfGraph- Returns:
- an iterator over Derivation records or null if there is no derivation information available for this triple.
-
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 -
logDerivation
Log a derivation record against the given triple.- Specified by:
logDerivationin interfaceBackwardRuleInfGraphI
-
findDataMatches
Match a pattern just against the stored data (raw data, schema, axioms) but no derivation.- Specified by:
findDataMatchesin interfaceBackwardRuleInfGraphI
-
processBuiltin
Process a call to a builtin predicate- Specified by:
processBuiltinin interfaceBackwardRuleInfGraphI- Parameters:
clause- the Functor representing the callenv- the BindingEnvironment for this callrule- the rule which is invoking this call- Returns:
- true if the predicate succeeds
-
silentAdd
Assert a new triple in the deduction graph, bypassing any processing machinery.- Specified by:
silentAddin interfaceSilentAddI
-
getTemp
Retrieve or create a bNode representing an inferred property value.- Specified by:
getTempin interfaceBackwardRuleInfGraphI- Parameters:
instance- the base instance node to which the property appliesprop- the property node whose value is being inferredpclass- the (optional, can be null) class for the inferred value.- Returns:
- the bNode representing the property value
-