Package com.yahoo.prelude.semantics.rule
Class ProductionRule
- java.lang.Object
-
- com.yahoo.prelude.semantics.rule.ProductionRule
-
- Direct Known Subclasses:
AddingProductionRule
,ReplacingProductionRule
public abstract class ProductionRule extends java.lang.Object
A query rewriting rule.- Author:
- bratseth
-
-
Constructor Summary
Constructors Constructor Description ProductionRule()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Condition
getCondition()
ProductionList
getProduction()
protected abstract java.lang.String
getSymbol()
Returns the symbol of this production rule.boolean
isLoop()
Returns true if it is known that this rule matches its own output.void
makeReferences(RuleBase rules)
boolean
matches(RuleEvaluation e)
Returns whether this rule matches the given queryjava.util.Set<java.lang.String>
matchReferences()
Returns the set of context names the production of this rule referencesvoid
produce(RuleEvaluation e)
Carries out the production of this rulevoid
setCondition(Condition condition)
Sets what must be true for this rule to be truevoid
setProduction(ProductionList production)
Sets what is produced when this rule is truejava.lang.String
toString()
Returns the canonical string representation of this rule.
-
-
-
Method Detail
-
setCondition
public void setCondition(Condition condition)
Sets what must be true for this rule to be true
-
getCondition
public Condition getCondition()
-
setProduction
public void setProduction(ProductionList production)
Sets what is produced when this rule is true
-
getProduction
public ProductionList getProduction()
-
matches
public boolean matches(RuleEvaluation e)
Returns whether this rule matches the given query
-
matchReferences
public java.util.Set<java.lang.String> matchReferences()
Returns the set of context names the production of this rule references- Returns:
- an unmodifiable Set of condition context name Strings
-
makeReferences
public void makeReferences(RuleBase rules)
-
produce
public void produce(RuleEvaluation e)
Carries out the production of this rule
-
toString
public java.lang.String toString()
Returns the canonical string representation of this rule. This string representation can always be reparsed to produce an identical rule to this one.- Overrides:
toString
in classjava.lang.Object
-
getSymbol
protected abstract java.lang.String getSymbol()
Returns the symbol of this production rule. All rules are on the formcondition symbol production
.
-
isLoop
public boolean isLoop()
Returns true if it is known that this rule matches its own output. If it does, it will only be evaluated once, to avoid infinite loops. This default implementation returns false;
-
-