public final class CommonGramsFilter extends TokenFilter
PositionIncrementAttribute.setPositionIncrement(int). Bigrams have a type
of GRAM_TYPE Example:
AttributeSource.State| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
GRAM_TYPE |
inputDEFAULT_TOKEN_ATTRIBUTE_FACTORY| Constructor and Description |
|---|
CommonGramsFilter(TokenStream input,
CharArraySet commonWords)
Construct a token stream filtering the given input using a Set of common
words to create bigrams.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
incrementToken()
Inserts bigrams for common words into a token stream.
|
void |
reset()
This method is called by a consumer before it begins consumption using
TokenStream.incrementToken(). |
close, endaddAttribute, addAttributeImpl, captureState, clearAttributes, cloneAttributes, copyTo, endAttributes, equals, getAttribute, getAttributeClassesIterator, getAttributeFactory, getAttributeImplsIterator, hasAttribute, hasAttributes, hashCode, reflectAsString, reflectWith, removeAllAttributes, restoreState, toStringpublic static final java.lang.String GRAM_TYPE
public CommonGramsFilter(TokenStream input, CharArraySet commonWords)
input - TokenStream input in filter chaincommonWords - The set of common words.public boolean incrementToken()
throws java.io.IOException
incrementToken in class TokenStreamjava.io.IOExceptionpublic void reset()
throws java.io.IOException
TokenFilterTokenStream.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., Tokenizer will
throw IllegalStateException on further usage).
NOTE:
The default implementation chains the call to the input TokenStream, so
be sure to call super.reset() when overriding this method.
reset in class TokenFilterjava.io.IOExceptionCopyright © 2000–2025 The Apache Software Foundation. All rights reserved.