java.lang.Object
org.apache.lucene.util.AttributeSource
org.apache.lucene.analysis.TokenStream
org.apache.lucene.analysis.TokenFilter
org.apache.lucene.monitor.SuffixingNGramTokenFilter
- All Implemented Interfaces:
Closeable,AutoCloseable,Unwrappable<TokenStream>
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.lucene.util.AttributeSource
AttributeSource.State -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Stringprivate intprivate intprivate intprivate intprivate intprivate char[]private intprivate final KeywordAttributeprivate final intprivate final OffsetAttributeprivate final PositionIncrementAttributeprivate final PositionLengthAttributeprivate final CharArraySetprivate final CharArraySetprivate final Stringprivate final CharTermAttributeprivate intprivate intFields inherited from class org.apache.lucene.analysis.TokenFilter
inputFields inherited from class org.apache.lucene.analysis.TokenStream
DEFAULT_TOKEN_ATTRIBUTE_FACTORY -
Constructor Summary
ConstructorsConstructorDescriptionSuffixingNGramTokenFilter(TokenStream input, String suffix, String wildcardToken, int maxTokenLength) Creates SuffixingNGramTokenFilter. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanReturns the next token in the stream, or null at EOS.voidreset()This method is called by a consumer before it begins consumption usingTokenStream.incrementToken().Methods inherited from class org.apache.lucene.analysis.TokenFilter
close, end, unwrapMethods inherited from class org.apache.lucene.util.AttributeSource
addAttribute, addAttributeImpl, captureState, clearAttributes, cloneAttributes, copyTo, endAttributes, equals, getAttribute, getAttributeClassesIterator, getAttributeFactory, getAttributeImplsIterator, hasAttribute, hasAttributes, hashCode, reflectAsString, reflectWith, removeAllAttributes, restoreState, toString
-
Field Details
-
suffix
-
maxTokenLength
private final int maxTokenLength -
anyToken
-
curTermBuffer
private char[] curTermBuffer -
curTermLength
private int curTermLength -
curCodePointCount
private int curCodePointCount -
curGramSize
private int curGramSize -
curPos
private int curPos -
curPosInc
private int curPosInc -
curPosLen
private int curPosLen -
tokStart
private int tokStart -
tokEnd
private int tokEnd -
termAtt
-
posIncAtt
-
posLenAtt
-
offsetAtt
-
keywordAtt
-
seenSuffixes
-
seenInfixes
-
-
Constructor Details
-
SuffixingNGramTokenFilter
public SuffixingNGramTokenFilter(TokenStream input, String suffix, String wildcardToken, int maxTokenLength) Creates SuffixingNGramTokenFilter.- Parameters:
input-TokenStreamholding the input to be tokenizedsuffix- a string to suffix to all ngramswildcardToken- a token to emit if the input token is longer than maxTokenLengthmaxTokenLength- tokens longer than this will not be ngrammed
-
-
Method Details
-
incrementToken
Returns the next token in the stream, or null at EOS.- Specified by:
incrementTokenin classTokenStream- Returns:
- false for end of stream; true otherwise
- Throws:
IOException
-
reset
Description copied from class:TokenFilterThis method is called by a consumer before it begins consumption usingTokenStream.incrementToken().Resets this stream to a clean state. Stateful implementations must implement this method so that they can be reused, just as if they had been created fresh.
If you override this method, always call
super.reset(), otherwise some internal state will not be correctly reset (e.g.,Tokenizerwill throwIllegalStateExceptionon further usage).NOTE: The default implementation chains the call to the input TokenStream, so be sure to call
super.reset()when overriding this method.- Overrides:
resetin classTokenFilter- Throws:
IOException
-