Package com.semedy.reasoner.api.logic
Class Rule
java.lang.Object
com.semedy.reasoner.api.logic.Rule
object to represent a rule.
A rule must have a unique identifier.
A rule must have a unique identifier.
- Author:
- angele
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclone a rule.boolean
getBody
(int i) returns body literal at index iint
get the number of body literalsLiteral[]
get all body literalsget stored debug infoget the documentation textgetHead()
returns the head of the rule, null if rule is a queryreturns the unique identifier of the ruleget a normalized version (all variables are renamed to Xi)return a variable renamingint
get the rule stratumgetText()
get the original rule textreturns for each variable how often it occurs in rulereturns a list of all rule variablesreturns all rule variable positions as bitsetint
hashCode()
boolean
Is rule used for partitioning the rule set?void
mergeInfoIntoRule
(Rule target) Move all info like variable renamings, rule text to new rule.void
set debug info to literalvoid
attach a documentation text to the rulevoid
Is rule used for partitioning the rule set.void
setStratum
(int s) set the rule stratumvoid
attach the original rule text (used for editors)toString()
toString
(SymbolTable symbols) toString
(SymbolTable symbols, List<Rule> aggregationRules) void
variableRenamedTo
(Variable oldVariable, Variable newVariable) Add a variable renaming.
-
Constructor Details
-
Rule
- Throws:
IDBException
-
Rule
- Throws:
IDBException
-
-
Method Details
-
cloneRule
clone a rule.- Returns:
- Throws:
IDBException
-
getBodyLiterals
get all body literals- Returns:
-
getNormalized
get a normalized version (all variables are renamed to Xi)- Returns:
- normalized version of rule
- Throws:
IDBException
-
getVariableOccurrences
returns for each variable how often it occurs in rule- Returns:
- map how often a variable occurs
-
getHead
returns the head of the rule, null if rule is a query- Returns:
-
getBody
returns body literal at index i- Parameters:
i
-- Returns:
-
getBodyLength
public int getBodyLength()get the number of body literals- Returns:
-
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
attach a documentation text to the rule- Parameters:
d
-
-
getDocumentation
get the documentation text- Returns:
-
setText
attach the original rule text (used for editors)- Parameters:
s
-
-
getText
get the original rule text- Returns:
-
getVariables
returns a list of all rule variables- Returns:
-
getVariablesAsBits
returns all rule variable positions as bitset- Returns:
-
toString
-
setParitioned
public void setParitioned()Is rule used for partitioning the rule set.
Used for partitioning of rules for threaded reasoning -
setDebugInfo
set debug info to literal- Parameters:
s
-
-
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
- Throws:
IOException
SemReasonerException
-
toString
public String toString(SymbolTable symbols, List<Rule> aggregationRules) throws IOException, SemReasonerException - Throws:
IOException
SemReasonerException
-
hashCode
public int hashCode() -
equals
-
variableRenamedTo
Add a variable renaming.
Done for renaming variables in queries during rewriting.- Parameters:
newVariable
-oldVariable
-
-
getOriginalVariableName
return a variable renaming- Parameters:
v
-- Returns:
-
mergeInfoIntoRule
Move all info like variable renamings, rule text to new rule.
Used during rewriting- Parameters:
target
-
-