Package org.apache.jena.reasoner.rulesys
Class GenericRuleReasoner
java.lang.Object
org.apache.jena.reasoner.rulesys.FBRuleReasoner
org.apache.jena.reasoner.rulesys.GenericRuleReasoner
- All Implemented Interfaces:
Reasoner
,RuleReasoner
- Direct Known Subclasses:
OWLMicroReasoner
,OWLMiniReasoner
,RDFSForwardRuleReasoner
,RDFSRuleReasoner
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.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Class used as an enum for describing rule modes. -
Field Summary
Modifier and TypeFieldDescriptionstatic final GenericRuleReasoner.RuleMode
Constant - the mode description for pure backward chainingboolean
Flag, if true then find results will be filtered to remove functors and illegal RDFstatic final GenericRuleReasoner.RuleMode
Constant - the mode description for pure forward chainingstatic final GenericRuleReasoner.RuleMode
Constant - the mode description for pure forward chaining, using RETE enginestatic final GenericRuleReasoner.RuleMode
Constant - the mode description for mixed forward/backward, this is the default mode -
Constructor Summary
ConstructorDescriptionGenericRuleReasoner
(List<Rule> rules) Constructor.GenericRuleReasoner
(List<Rule> rules, ReasonerFactory factory) ConstructorGenericRuleReasoner
(ReasonerFactory factory, Resource configuration) Constructor -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a new preprocessing hook defining an operation that should be run when the inference graph is being prepared.Attach the reasoner to a set of RDF data to process.bindSchema
(Graph tbox) Precompute the implications of a schema graph.void
Remove a preprocessing hook.void
setFunctorFiltering
(boolean param) Set to true to cause functor-valued literals to be dropped from rule output.void
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
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 org.apache.jena.reasoner.rulesys.FBRuleReasoner
addDescription, addRules, bindSchema, getBoundSchema, getGraphCapabilities, getReasonerCapabilities, getRules, isTraceOn, loadRules, setDerivationLogging, setParameter, setTraceOn, supportsProperty, tablePredicate
-
Field Details
-
filterFunctors
public boolean filterFunctorsFlag, if true then find results will be filtered to remove functors and illegal RDF -
FORWARD
Constant - the mode description for pure forward chaining -
FORWARD_RETE
Constant - the mode description for pure forward chaining, using RETE engine -
BACKWARD
Constant - the mode description for pure backward chaining -
HYBRID
Constant - the mode description for mixed forward/backward, this is the default mode
-
-
Constructor Details
-
GenericRuleReasoner
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
Constructor- Parameters:
factory
- the parent reasoner factory which is consulted to answer capability questionsconfiguration
- RDF node to configure the rule set and mode, can be null
-
GenericRuleReasoner
Constructor- Parameters:
rules
- a list of Rule instances which defines the ruleset to processfactory
- the parent reasoner factory which is consulted to answer capability questions
-
-
Method Details
-
setMode
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
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 interfaceRuleReasoner
- Overrides:
setRules
in classFBRuleReasoner
- 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 intersection 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
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 guaranteed to be implemented for the HYBRID mode. -
removePreprocessingHook
Remove a preprocessing hook. defining an operation that -
bindSchema
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 interfaceReasoner
- Overrides:
bindSchema
in classFBRuleReasoner
- 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
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 interfaceReasoner
- Overrides:
bind
in classFBRuleReasoner
- 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.
-