Class Rule

java.lang.Object
com.semedy.reasoner.api.logic.Rule

public class Rule extends Object
object to represent a rule.
A rule must have a unique identifier.
Author:
angele
  • Constructor Details

  • Method Details

    • cloneRule

      public Rule cloneRule() throws IDBException
      clone a rule.
      Returns:
      Throws:
      IDBException
    • getBodyLiterals

      public Literal[] getBodyLiterals()
      get all body literals
      Returns:
    • getNormalized

      public Rule getNormalized() throws IDBException
      get a normalized version (all variables are renamed to Xi)
      Returns:
      normalized version of rule
      Throws:
      IDBException
    • getVariableOccurrences

      public Map<Variable,Integer> getVariableOccurrences()
      returns for each variable how often it occurs in rule
      Returns:
      map how often a variable occurs
    • getHead

      public Literal getHead()
      returns the head of the rule, null if rule is a query
      Returns:
    • getBody

      public Literal getBody(int i)
      returns body literal at index i
      Parameters:
      i -
      Returns:
    • getBodyLength

      public int getBodyLength()
      get the number of body literals
      Returns:
    • getIdentifier

      public String getIdentifier()
      returns the unique identifier of the rule
      Returns:
    • getStratum

      public int getStratum()
      get the rule stratum
      Returns:
    • setStratum

      public void setStratum(int s)
      set the rule stratum
      Parameters:
      s -
    • setDocumentation

      public void setDocumentation(String d)
      attach a documentation text to the rule
      Parameters:
      d -
    • getDocumentation

      public String getDocumentation()
      get the documentation text
      Returns:
    • setText

      public void setText(String s)
      attach the original rule text (used for editors)
      Parameters:
      s -
    • getText

      public String getText()
      get the original rule text
      Returns:
    • getVariables

      public List<Variable> getVariables()
      returns a list of all rule variables
      Returns:
    • getVariablesAsBits

      public BitSet getVariablesAsBits()
      returns all rule variable positions as bitset
      Returns:
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • setParitioned

      public void setParitioned()
      Is rule used for partitioning the rule set.
      Used for partitioning of rules for threaded reasoning
    • setDebugInfo

      public void setDebugInfo(String s)
      set debug info to literal
      Parameters:
      s -
    • getDebugInfo

      public String getDebugInfo()
      get stored debug info
      Returns:
    • isPartitioned

      public boolean isPartitioned()
      Is rule used for partitioning the rule set?
      Used for partitioning of rules for threaded reasoning
      Returns:
    • toString

      public String toString(SymbolTable symbols) throws IOException, SemReasonerException
      Throws:
      IOException
      SemReasonerException
    • toString

      public String toString(SymbolTable symbols, List<Rule> aggregationRules) throws IOException, SemReasonerException
      Throws:
      IOException
      SemReasonerException
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • variableRenamedTo

      public void variableRenamedTo(Variable oldVariable, Variable newVariable)
      Add a variable renaming.
      Done for renaming variables in queries during rewriting.
      Parameters:
      newVariable -
      oldVariable -
    • getOriginalVariableName

      public String getOriginalVariableName(Variable v)
      return a variable renaming
      Parameters:
      v -
      Returns:
    • mergeInfoIntoRule

      public void mergeInfoIntoRule(Rule target)
      Move all info like variable renamings, rule text to new rule.
      Used during rewriting
      Parameters:
      target -