Package com.yahoo.prelude.query
Class PhraseSegmentItem
- All Implemented Interfaces:
BlockItem,HasIndexItem,IndexedItem,TaggableItem,Cloneable
A term which contains a fixed length phrase, a collection of word terms,
resulting from a single segmentation operation.
- 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, documentFrequency, explicitSignificance, significance, uniqueID -
Constructor Summary
ConstructorsConstructorDescriptionPhraseSegmentItem(AndSegmentItem andSegment) Creates a phrase containing the same words and state (as pertinent) as the given SegmentAndItem.PhraseSegmentItem(String rawWord, boolean isFromQuery, boolean stemmed) PhraseSegmentItem(String rawWord, String current, boolean isFromQuery, boolean stemmed) Creates a phrase segment from stringsPhraseSegmentItem(String rawWord, String current, boolean isFromQuery, boolean stemmed, Substring substring) -
Method Summary
Modifier and TypeMethodDescriptionbooleanacceptsItemsOfType(Item.ItemType itemType) voidInserts the item at a position and increases the index of existing items starting on this position by onevoidAdds subitem.protected voidappendBodyString(StringBuilder buffer) Override to append the item body in the canonical query language of this item.protected voidappendHeadingString(StringBuilder buffer) Segment phrase items uses a empty heading instead of "SPHRASE "voidintencode(ByteBuffer buffer) intencodeContent(ByteBuffer buffer) protected voidencodeThis(ByteBuffer buffer) Encodes just this item, not its regular subitems, to the given buffer.booleanReturns whether this item is of the same class and contains the same state as the given item.Returns the single child of this, if this can be omitted without changes to recall semantics.Return the searchable term contents of this item.Return the enumerated type of this item.getName()Returns the name of this itemgetTermItem(int index) Returns a subitem as a term iteminthashCode()booleanvoidsetExplicit(boolean explicit) voidsetIndexName(String index) Sets the name of the index to searchReplaces the item at the given index.voidsetWeight(int weight) Sets the relative importance of this termprotected booleanReturns false, no parenthezes for phrasesMethods inherited from class com.yahoo.prelude.query.IndexedSegmentItem
appendIndexString, getIndexNameMethods inherited from class com.yahoo.prelude.query.TaggableSegmentItem
getConnectedItem, getConnectivity, getDocumentFrequency, getSignificance, getUniqueID, hasExplicitSignificance, hasUniqueID, setConnectivity, setDocumentFrequency, setExplicitSignificance, setSignificance, setUniqueIDMethods inherited from class com.yahoo.prelude.query.SegmentItem
clone, getNormalized, getNumWords, getOrigin, getRawWord, getSegmentingRule, isFromQuery, isFromUser, isLocked, isStemmed, isWords, lock, removeItem, removeItem, setFromUser, setSegmentingRule, setStemmed, shouldFoldIntoWand, shouldFoldIntoWand, stringValueMethods inherited from class com.yahoo.prelude.query.CompositeItem
adding, encodingArity, ensureNotInSubtree, getItem, getItemCount, getItemIndex, getItemIterator, getTermCount, itemsMethods inherited from class com.yahoo.prelude.query.Item
addAnnotation, getAnnotation, getBytes, getCode, getCreator, getLabel, getLanguage, getParent, getWeight, hasAnnotation, hasConnectivityBackLink, hasPrefixMatchSemantics, isFilter, isFromSpecialToken, isProtected, isRanked, isRoot, putBytes, putString, setCreator, setFilter, setFromSpecialToken, setHasUniqueID, setLabel, setLanguage, setParent, setPositionData, setProtected, setRanked, toString, usePositionDataMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.yahoo.prelude.query.HasIndexItem
getNumWords
-
Constructor Details
-
PhraseSegmentItem
Creates a phrase containing the same words and state (as pertinent) as the given SegmentAndItem. -
PhraseSegmentItem
-
PhraseSegmentItem
Creates a phrase segment from strings- Parameters:
rawWord- the raw text as received in the requestcurrent- the normalized form of the raw text, or the raw text repeated if no normalized form is knownisFromQuery- whether this originates in the requeststemmed- whether this is stemmed
-
PhraseSegmentItem
-
-
Method Details
-
getItemType
Description copied from class:ItemReturn the enumerated type of this item.- Specified by:
getItemTypein classItem
-
getName
Description copied from class:ItemReturns the name of this item -
setIndexName
Description copied from class:IndexedSegmentItemSets the name of the index to search- Specified by:
setIndexNamein interfaceIndexedItem- Overrides:
setIndexNamein classIndexedSegmentItem
-
setWeight
public void setWeight(int weight) Description copied from class:ItemSets the relative importance of this term -
acceptsItemsOfType
- Overrides:
acceptsItemsOfTypein classCompositeItem
-
addItem
Adds subitem. The word will have its index name set to the index name of this phrase. If the item is a word, it will simply be added, if the item is a phrase, each of the words of the phrase will be added.- Overrides:
addItemin classSegmentItem- Throws:
IllegalArgumentException- if the given item is not a TermItem or PhraseItem
-
addItem
Description copied from class:CompositeItemInserts the item at a position and increases the index of existing items starting on this position by one- Overrides:
addItemin classSegmentItem
-
setItem
Description copied from class:CompositeItemReplaces the item at the given index.- Overrides:
setItemin classCompositeItem- Parameters:
index- the (0-base) index of the item to replaceitem- the new item- Returns:
- the old item at this position. The parent of the old item is not cleared
-
extractSingleChild
Description copied from class:CompositeItemReturns the single child of this, if this can be omitted without changes to recall semantics.- Overrides:
extractSingleChildin classCompositeItem
-
getTermItem
Returns a subitem as a term item- Parameters:
index- the (0-base) index of the item to return- Throws:
IndexOutOfBoundsException- if there is no subitem at index
-
encodeThis
Description copied from class:CompositeItemEncodes just this item, not its regular subitems, to the given buffer.- Overrides:
encodeThisin classIndexedSegmentItem
-
encode
- Overrides:
encodein classCompositeItem
-
encodeContent
-
shouldParenthesize
protected boolean shouldParenthesize()Returns false, no parenthezes for phrases- Overrides:
shouldParenthesizein classCompositeItem
-
appendHeadingString
Segment phrase items uses a empty heading instead of "SPHRASE "- Overrides:
appendHeadingStringin classItem
-
appendBodyString
Description copied from class:ItemOverride to append the item body in the canonical query language of this item. An item is usually represented by the string([itemName] [body])
The body must be appended by this method.- Overrides:
appendBodyStringin classCompositeItem
-
getIndexedString
Description copied from interface:IndexedItemReturn the searchable term contents of this item.- Specified by:
getIndexedStringin interfaceIndexedItem- Specified by:
getIndexedStringin classIndexedSegmentItem- Returns:
- a string representation of what is presumably stored in an index which will match this item
-
isExplicit
public boolean isExplicit() -
setExplicit
public void setExplicit(boolean explicit) -
disclose
- Overrides:
disclosein classIndexedSegmentItem
-
equals
Description copied from class:CompositeItemReturns whether this item is of the same class and contains the same state as the given item.- Overrides:
equalsin classIndexedSegmentItem
-
hashCode
public int hashCode()- Overrides:
hashCodein classIndexedSegmentItem
-