Package com.yahoo.prelude.query
Class SegmentItem
- java.lang.Object
-
- com.yahoo.prelude.query.Item
-
- com.yahoo.prelude.query.CompositeItem
-
- com.yahoo.prelude.query.SegmentItem
-
- All Implemented Interfaces:
BlockItem
,HasIndexItem
,java.lang.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
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.yahoo.prelude.query.Item
Item.ItemCreator, Item.ItemType
-
-
Field Summary
-
Fields inherited from class com.yahoo.prelude.query.Item
connectedBacklink, connectedItem, connectivity, DEFAULT_WEIGHT, explicitSignificance, significance, uniqueID
-
-
Constructor Summary
Constructors Constructor Description SegmentItem(java.lang.String rawWord, java.lang.String current, boolean isFromQuery, boolean stemmed)
Creates a new segment itemSegmentItem(java.lang.String rawWord, java.lang.String current, boolean isFromQuery, boolean stemmed, Substring origin)
Creates a new segment item
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addItem(int index, Item item)
Inserts the item at a position and increases the index of existing items starting on this position by onevoid
addItem(Item item)
SegmentItem
clone()
Return a deep copy of this objectvoid
disclose(com.yahoo.prelude.query.textualrepresentation.Discloser discloser)
java.lang.String
getNormalized()
int
getNumWords()
Substring
getOrigin()
Returns null right nowjava.lang.String
getRawWord()
The untransformed raw text from the user serving as base for this item.SegmentingRule
getSegmentingRule()
If the block has to be resegmented, what operator should be chosen if it is necessary to change operator?boolean
isFromQuery()
Is this block of text conceptually from the user query?boolean
isFromUser()
boolean
isLocked()
Whether this composite is in a mutable state.boolean
isStemmed()
boolean
isWords()
Does this item represent "usual words"?void
lock()
Make composite immutable if this is supported.Item
removeItem(int index)
Removes the item at the given indexboolean
removeItem(Item item)
Removes the given item.void
setFromUser(boolean isFromUser)
void
setSegmentingRule(SegmentingRule segmentingRule)
java.lang.String
stringValue()
Returns the value of this term as a string-
Methods inherited from class com.yahoo.prelude.query.CompositeItem
adding, appendBodyString, encode, encodeThis, encodingArity, ensureNotInSubtree, equals, extractSingleChild, getItem, getItemCount, getItemIndex, getItemIterator, getTermCount, hashCode, items, setIndexName, setItem, shouldParenthize
-
Methods inherited from class com.yahoo.prelude.query.Item
addAnnotation, appendHeadingString, getAnnotation, getBytes, getCode, getCreator, getItemType, getLabel, getLanguage, getName, getParent, getWeight, hasAnnotation, hasConnectivityBackLink, hasUniqueID, isFilter, isFromSpecialToken, isProtected, isRanked, isRoot, putBytes, putString, setCreator, setFilter, setFromSpecialToken, setHasUniqueID, setLabel, setLanguage, setParent, setPositionData, setProtected, setRanked, setWeight, toString, usePositionData
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.yahoo.prelude.query.HasIndexItem
getIndexName
-
-
-
-
Constructor Detail
-
SegmentItem
public SegmentItem(java.lang.String rawWord, java.lang.String current, boolean isFromQuery, boolean stemmed)
Creates a new segment item- Parameters:
rawWord
- the raw form of this segment as received in the requestcurrent
- the current transformed version of the raw form, or the raw form repeated if no normalized form is knownisFromQuery
- whether this segment stems from the query received in the requeststemmed
- whether this is stemmed
-
SegmentItem
public SegmentItem(java.lang.String rawWord, java.lang.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 requestcurrent
- the current transformed version of the raw form, or the raw form repeated if no normalized form is knownisFromQuery
- whether this segment stems from the query received in the requeststemmed
- whether this is stemmedorigin
- TODO
-
-
Method Detail
-
getRawWord
public java.lang.String getRawWord()
Description copied from interface:BlockItem
The untransformed raw text from the user serving as base for this item.- Specified by:
getRawWord
in interfaceBlockItem
-
getNormalized
public java.lang.String getNormalized()
-
stringValue
public java.lang.String stringValue()
Description copied from interface:BlockItem
Returns the value of this term as a string- Specified by:
stringValue
in interfaceBlockItem
-
isFromQuery
public boolean isFromQuery()
Description copied from interface:BlockItem
Is this block of text conceptually from the user query?- Specified by:
isFromQuery
in interfaceBlockItem
-
lock
public void lock()
Description copied from class:CompositeItem
Make composite immutable if this is supported.- Overrides:
lock
in classCompositeItem
-
isLocked
public boolean isLocked()
Description copied from class:CompositeItem
Whether this composite is in a mutable state.- Overrides:
isLocked
in classCompositeItem
-
getNumWords
public int getNumWords()
- Specified by:
getNumWords
in interfaceHasIndexItem
- Returns:
- how many phrase words does this item contain
-
addItem
public void addItem(Item item)
- Overrides:
addItem
in classCompositeItem
-
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 classCompositeItem
-
removeItem
public Item removeItem(int index)
Description copied from class:CompositeItem
Removes the item at the given index- Overrides:
removeItem
in classCompositeItem
- 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 classCompositeItem
- 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 classCompositeItem
-
isWords
public boolean isWords()
Description copied from interface:BlockItem
Does this item represent "usual words"?
-
isFromUser
public boolean isFromUser()
-
setFromUser
public void setFromUser(boolean isFromUser)
-
getOrigin
public Substring getOrigin()
Returns null right now
-
disclose
public void disclose(com.yahoo.prelude.query.textualrepresentation.Discloser discloser)
- Overrides:
disclose
in classCompositeItem
-
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 interfaceBlockItem
-
setSegmentingRule
public void setSegmentingRule(SegmentingRule segmentingRule)
-
-