Package org.apache.jena.reasoner.rulesys
Class FBRuleReasoner
java.lang.Object
org.apache.jena.reasoner.rulesys.FBRuleReasoner
- All Implemented Interfaces:
Reasoner
,RuleReasoner
- Direct Known Subclasses:
GenericRuleReasoner
,OWLFBRuleReasoner
,RDFSFBRuleReasoner
Rule-based reasoner interface. This is the default rule reasoner to use.
It supports both forward reasoning and backward reasoning, including use
of forward rules to generate and instantiate backward rules.
-
Constructor Summary
ConstructorDescriptionFBRuleReasoner
(List<Rule> rules) Constructor.FBRuleReasoner
(List<Rule> rules, ReasonerFactory factory) ConstructorFBRuleReasoner
(ReasonerFactory factory) ConstructorFBRuleReasoner
(ReasonerFactory factory, Resource configuration) Constructor -
Method Summary
Modifier and TypeMethodDescriptionvoid
addDescription
(Model configSpec, Resource base) Add a configuration description for this reasoner into a partial configuration specification model.Add the given rules to the current set and answer this Reasoner.Attach the reasoner to a set of RDF data to process.bindSchema
(Graph tbox) Precompute the implications of a schema graph.bindSchema
(Model tbox) Precompute the implications of a schema Model.Answer the schema graph bound into this reasoner, or null if there isn't one.Return the Jena Graph Capabilities that the inference graphs generated by this reasoner are expected to conform to.Return a description of the capabilities of this reasoner encoded in RDF.getRules()
Return the list of Rules used by this reasonerboolean
Return the state of the trace flag.If set to true then rule firings are logged out to the Log at "INFO" level.Answer the list of rules loaded from the given filename.void
setDerivationLogging
(boolean logOn) Switch on/off derivation logging.void
setParameter
(Property parameter, Object value) Set a configuration parameter for the reasoner.void
Set (or change) the rule set that this reasoner should execute.void
setTraceOn
(boolean state) Set the state of the trace flag.boolean
supportsProperty
(Property property) Determine whether the given property is recognized and treated specially by this reasoner.void
tablePredicate
(Node predicate) Register an RDF predicate as one whose presence in a goal should force the goal to be tabled.
-
Constructor Details
-
FBRuleReasoner
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
-
FBRuleReasoner
Constructor- Parameters:
factory
- the parent reasoner factory which is consulted to answer capability questions
-
FBRuleReasoner
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
-
FBRuleReasoner
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
-
addRules
Add the given rules to the current set and answer this Reasoner. Provided so that the Factory can deal out reasoners with specified rulesets. There may well be a better way to arrange this. -
getReasonerCapabilities
Return a description of the capabilities of this reasoner encoded in RDF. These capabilities may be static or may depend on configuration information supplied at construction time. May be null if there are no useful capabilities registered.- Specified by:
getReasonerCapabilities
in interfaceReasoner
-
getBoundSchema
Answer the schema graph bound into this reasoner, or null if there isn't one. (Added mainly for testing purposes, which is why it isn't part of the Reasoner API.) -
addDescription
Add a configuration description for this reasoner into a partial configuration specification model.- Specified by:
addDescription
in interfaceReasoner
- Parameters:
configSpec
- a Model into which the configuration information should be placedbase
- the Resource to which the configuration parameters should be added.
-
supportsProperty
Determine whether the given property is recognized and treated specially by this reasoner. This is a convenience packaging of a special case of getCapabilities.- Specified by:
supportsProperty
in interfaceReasoner
- Parameters:
property
- the property which we want to ask the reasoner about, given as a Node since this is part of the SPI rather than API- Returns:
- true if the given property is handled specially by the reasoner.
-
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
- 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.
-
bindSchema
Precompute the implications of a schema Model. The statements in the graph will be combined with the data when the final InfGraph is created.- Specified by:
bindSchema
in interfaceReasoner
- 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
- 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.
-
setRules
Set (or change) the rule set that this reasoner should execute.- Specified by:
setRules
in interfaceRuleReasoner
- Parameters:
rules
- a list of Rule objects
-
getRules
Return the list of Rules used by this reasoner- Specified by:
getRules
in interfaceRuleReasoner
- Returns:
- a List of Rule objects
-
loadRules
Answer the list of rules loaded from the given filename. May throw a ReasonerException wrapping an IOException. -
tablePredicate
Register an RDF predicate as one whose presence in a goal should force the goal to be tabled. This is better done directly in the rule set. -
setDerivationLogging
public void setDerivationLogging(boolean logOn) Switch on/off derivation logging. If set to true then the InfGraph created from the bind operation will start life with recording of derivations switched on. This is currently only of relevance to rule-based reasoners.Default - false.
- Specified by:
setDerivationLogging
in interfaceReasoner
-
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 Logger at "INFO" level. -
isTraceOn
public boolean isTraceOn()Return the state of the trace flag.If set to true then rule firings are logged out to the Log at "INFO" level. -
setParameter
Set a configuration parameter for the reasoner. The supported parameters are:- PROPderivationLogging - set to true to enable recording all rule derivations
- PROPtraceOn - set to true to enable verbose trace information to be sent to the logger INFO channel
- Specified by:
setParameter
in interfaceReasoner
- Parameters:
parameter
- the property identifying the parameter to be changedvalue
- the new value for the parameter, typically this is a wrapped java object like Boolean or Integer.- Throws:
IllegalParameterException
- if the parameter is unknown
-
getGraphCapabilities
Return the Jena Graph Capabilities that the inference graphs generated by this reasoner are expected to conform to.- Specified by:
getGraphCapabilities
in interfaceReasoner
-