Class RuleEvaluation

java.lang.Object
com.yahoo.prelude.semantics.engine.RuleEvaluation

public class RuleEvaluation extends Object
A particular evaluation of a particular rule.
Author:
bratseth
  • Constructor Details

    • RuleEvaluation

      public RuleEvaluation(Evaluation owner)
  • Method Details

    • initialize

      public void initialize(List<FlattenedItem> list, int startPosition)
    • setMatchReferences

      public void setMatchReferences(Set<String> matchReferences)
    • currentItem

      public FlattenedItem currentItem()
      Returns the current term item to look at, or null if there are no more elements
    • previousItem

      public FlattenedItem previousItem()
    • currentPosition

      public int currentPosition()
      Returns the position of the current item
    • setPosition

      public void setPosition(int position)
      Sets the current position
    • itemCount

      public int itemCount()
      Returns the total number of items to match in this evaluation
    • getValue

      public Object getValue()
      Returns the last value returned by a condition in this evaluation, or null
    • setValue

      public void setValue(Object value)
      Sets the last value returned by a condition in this evaluatiino, or null
    • isInNegation

      public boolean isInNegation()
      Returns whether we are evaluating inside a condition which inverts the truth value
    • setInNegation

      public void setInNegation(boolean inNegation)
      sets whether we are evaluating inside a condition which inverts the truth value
    • getPosition

      public int getPosition()
      Returns the current position into the terms this evaluates over
    • setCurrentLabel

      public String setCurrentLabel(String currentLabel)
      Sets a new current label and returns the previous one
    • getCurrentLabel

      public String getCurrentLabel()
    • next

      public FlattenedItem next()
      Advances currentItem to the next term item and returns thatItem. If the current item before this call is the last item, this will return (and set currentItem to) null.
    • entering

      public void entering(String context)
    • leaving

      public void leaving(String context)
    • addMatch

      public void addMatch(FlattenedItem item, String replaceString)
      Adds a match
      Parameters:
      item - the match to add
      replaceString - the string to replace this match by, usually the item.getIndexedValue()
    • getReferencedMatches

      public ReferencedMatches getReferencedMatches(String name)
      Returns the referenced matches for a context name, or null if none
    • getReferencedMatchCount

      public int getReferencedMatchCount()
    • getNonreferencedMatchCount

      public int getNonreferencedMatchCount()
    • getEvaluation

      public Evaluation getEvaluation()
      Returns the evaluation this belongs to
    • addItems

      public void addItems(List<Item> items, TermType termType)
      Adds an item to the query being evaluated in a way consistent with the query type
    • removeItem

      public void removeItem(Item item)
    • removeItemByIdentity

      public void removeItemByIdentity(Item item)
    • removeItem

      public void removeItem(int position, Item item)
      Removes an item, prefers the one at/close to the given position if there are multiple ones
    • insertItems

      public void insertItems(List<Item> items, CompositeItem parent, int index, TermType termType)
      Inserts an item to the query being evaluated in a way consistent with the query type
      Parameters:
      items - the items to insert
      parent - the parent of this item, or null to set the root
      index - the index at which to insert this into the parent
      termType - the kind of item to index, this decides the resulting structure
    • items

      public List<FlattenedItem> items()
      Returns a read-only view of the items of this
    • getNonreferencedMatch

      public Match getNonreferencedMatch(int index)
    • trace

      public void trace(int level, String string)
    • getTraceLevel

      public int getTraceLevel()
    • indentTrace

      public void indentTrace()
    • unindentTrace

      public void unindentTrace()
    • getChoicepoint

      public Choicepoint getChoicepoint(Condition condition, boolean create)
      Add a choice point to this evaluation
      Parameters:
      condition - the creating condition
      create - true to create this choicepoint if it is missing
      Returns:
      the choicepoint, or null if not present, and create is false
    • removeMatches

      public void removeMatches(ReferencedMatches matches)
      Remove all the terms recognized by this match