Class SegmentItem

All Implemented Interfaces:
BlockItem, HasIndexItem, Cloneable
Direct Known Subclasses:
AndSegmentItem, TaggableSegmentItem

public abstract class SegmentItem extends CompositeItem implements BlockItem
An immutable and'ing of a collection of sub-expressions. It does not extend AndItem to avoid code using instanceof handling it as an AndItem.
Author:
Steinar Knutsen
  • Constructor Details

    • SegmentItem

      public SegmentItem(String rawWord, String current, boolean isFromQuery, boolean stemmed)
      Creates a new segment item
      Parameters:
      rawWord - the raw form of this segment as received in the request
      current - the current transformed version of the raw form, or the raw form repeated if no normalized form is known
      isFromQuery - whether this segment stems from the query received in the request
      stemmed - whether this is stemmed
    • SegmentItem

      public SegmentItem(String rawWord, String current, boolean isFromQuery, boolean stemmed, Substring origin)
      Creates a new segment item
      Parameters:
      rawWord - the raw form of this segment as received in the request
      current - the current transformed version of the raw form, or the raw form repeated if no normalized form is known
      isFromQuery - whether this segment stems from the query received in the request
      stemmed - whether this is stemmed
      origin - the original text that led to this
  • Method Details

    • getRawWord

      public String getRawWord()
      Description copied from interface: BlockItem
      The untransformed raw text from the user serving as base for this item.
      Specified by:
      getRawWord in interface BlockItem
    • getNormalized

      public String getNormalized()
    • stringValue

      public String stringValue()
      Description copied from interface: BlockItem
      Returns the value of this term as a string
      Specified by:
      stringValue in interface BlockItem
    • isFromQuery

      public boolean isFromQuery()
      Description copied from interface: BlockItem
      Returns whether this block of text originates from a user and should therefore receive the normal processing applied to raw text (such as stemming).
      Specified by:
      isFromQuery in interface BlockItem
    • isStemmed

      public boolean isStemmed()
      Specified by:
      isStemmed in interface BlockItem
    • lock

      public void lock()
      Description copied from class: CompositeItem
      Make composite immutable if this is supported.
      Overrides:
      lock in class CompositeItem
    • isLocked

      public boolean isLocked()
      Description copied from class: CompositeItem
      Whether this composite is in a mutable state.
      Overrides:
      isLocked in class CompositeItem
    • getNumWords

      public int getNumWords()
      Description copied from interface: HasIndexItem
      Returns how many phrase words does this item contain
      Specified by:
      getNumWords in interface HasIndexItem
    • addItem

      public void addItem(Item item)
      Overrides:
      addItem in class CompositeItem
    • addItem

      public void addItem(int index, Item item)
      Description copied from class: CompositeItem
      Inserts the item at a position and increases the index of existing items starting on this position by one
      Overrides:
      addItem in class CompositeItem
    • removeItem

      public Item removeItem(int index)
      Description copied from class: CompositeItem
      Removes the item at the given index
      Overrides:
      removeItem in class CompositeItem
      Parameters:
      index - the index of the item to remove
      Returns:
      the removed item
    • removeItem

      public boolean removeItem(Item item)
      Description copied from class: CompositeItem
      Removes the given item. Does nothing if the item is not present.
      Overrides:
      removeItem in class CompositeItem
      Parameters:
      item - the item to remove
      Returns:
      whether the item was removed
    • clone

      public SegmentItem clone()
      Return a deep copy of this object
      Overrides:
      clone in class CompositeItem
    • isWords

      public boolean isWords()
      Description copied from interface: BlockItem
      Returns whether this item represents normal text
      Specified by:
      isWords in interface BlockItem
    • isFromUser

      public boolean isFromUser()
    • setFromUser

      public void setFromUser(boolean isFromUser)
    • getOrigin

      public Substring getOrigin()
      Returns null right now
      Specified by:
      getOrigin in interface BlockItem
    • disclose

      public void disclose(Discloser discloser)
      Overrides:
      disclose in class CompositeItem
    • getSegmentingRule

      public SegmentingRule getSegmentingRule()
      Description copied from interface: BlockItem
      If the block has to be resegmented, what operator should be chosen if it is necessary to change operator?
      Specified by:
      getSegmentingRule in interface BlockItem
    • setSegmentingRule

      public void setSegmentingRule(SegmentingRule segmentingRule)
    • equals

      public boolean equals(Object o)
      Description copied from class: CompositeItem
      Returns whether this item is of the same class and contains the same state as the given item.
      Overrides:
      equals in class CompositeItem
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class CompositeItem