Class GenericRuleReasoner

All Implemented Interfaces:
Reasoner, RuleReasoner
Direct Known Subclasses:
OWLMicroReasoner, OWLMiniReasoner, RDFSForwardRuleReasoner, RDFSRuleReasoner

public class GenericRuleReasoner extends FBRuleReasoner
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.
  • Field Details

    • filterFunctors

      public boolean filterFunctors
      Flag, if true then find results will be filtered to remove functors and illegal RDF

      public static final GenericRuleReasoner.RuleMode FORWARD
      Constant - the mode description for pure forward chaining

      public static final GenericRuleReasoner.RuleMode FORWARD_RETE
      Constant - the mode description for pure forward chaining, using RETE engine

      public static final GenericRuleReasoner.RuleMode BACKWARD
      Constant - the mode description for pure backward chaining
    • HYBRID

      public static final GenericRuleReasoner.RuleMode HYBRID
      Constant - the mode description for mixed forward/backward, this is the default mode
  • Constructor Details

    • GenericRuleReasoner

      public GenericRuleReasoner(List<Rule> rules)
      Constructor. This is the raw version that does not reference a ReasonerFactory and so has no capabilities description.
      rules - a list of Rule instances which defines the ruleset to process
    • GenericRuleReasoner

      public GenericRuleReasoner(ReasonerFactory factory, Resource configuration)
      factory - the parent reasoner factory which is consulted to answer capability questions
      configuration - RDF node to configure the rule set and mode, can be null
    • GenericRuleReasoner

      public GenericRuleReasoner(List<Rule> rules, ReasonerFactory factory)
      rules - a list of Rule instances which defines the ruleset to process
      factory - the parent reasoner factory which is consulted to answer capability questions
  • Method Details

    • setMode

      public void setMode(GenericRuleReasoner.RuleMode mode)
      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

      public void setRules(List<Rule> rules)
      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 interface RuleReasoner
      setRules in class FBRuleReasoner
      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

      public void addPreprocessingHook(RulePreprocessHook hook)
      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

      public void removePreprocessingHook(RulePreprocessHook hook)
      Remove a preprocessing hook. defining an operation that
    • bindSchema

      public Reasoner bindSchema(Graph tbox) throws ReasonerException
      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 interface Reasoner
      bindSchema in class FBRuleReasoner
      tbox - the ontology axioms or rule set encoded in RDF
      a reasoner instace which can be used to process a data graph
      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

      public InfGraph bind(Graph data) throws ReasonerException
      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 interface Reasoner
      bind in class FBRuleReasoner
      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).
      an inference graph through which the data+reasoner can be queried.
      ReasonerException - if the data is ill-formed according to the constraints imposed by this reasoner.