public final class StandardAnalyzer extends StopwordAnalyzerBase
StandardTokenizer
with LowerCaseFilter
and
StopFilter
, using a configurable list of stop words.Analyzer.ReuseStrategy, Analyzer.TokenStreamComponents
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_MAX_TOKEN_LENGTH
Default maximum allowed token length
|
stopwords
GLOBAL_REUSE_STRATEGY, PER_FIELD_REUSE_STRATEGY
Constructor and Description |
---|
StandardAnalyzer()
Builds an analyzer with no stop words.
|
StandardAnalyzer(CharArraySet stopWords)
Builds an analyzer with the given stop words.
|
StandardAnalyzer(Reader stopwords)
Builds an analyzer with the stop words from the given reader.
|
Modifier and Type | Method and Description |
---|---|
protected Analyzer.TokenStreamComponents |
createComponents(String fieldName)
Creates a new
Analyzer.TokenStreamComponents instance for this analyzer. |
int |
getMaxTokenLength()
Returns the current maximum token length
|
protected TokenStream |
normalize(String fieldName,
TokenStream in)
Wrap the given
TokenStream in order to apply normalization filters. |
void |
setMaxTokenLength(int length)
Set the max allowed token length.
|
getStopwordSet, loadStopwordSet, loadStopwordSet, loadStopwordSet
attributeFactory, close, getOffsetGap, getPositionIncrementGap, getReuseStrategy, getVersion, initReader, initReaderForNormalization, normalize, setVersion, tokenStream, tokenStream
public static final int DEFAULT_MAX_TOKEN_LENGTH
public StandardAnalyzer(CharArraySet stopWords)
stopWords
- stop wordspublic StandardAnalyzer()
public StandardAnalyzer(Reader stopwords) throws IOException
stopwords
- Reader to read stop words fromIOException
WordlistLoader.getWordSet(Reader)
public void setMaxTokenLength(int length)
LengthFilter
to remove long tokens. The default is
DEFAULT_MAX_TOKEN_LENGTH
.public int getMaxTokenLength()
setMaxTokenLength(int)
protected Analyzer.TokenStreamComponents createComponents(String fieldName)
Analyzer
Analyzer.TokenStreamComponents
instance for this analyzer.createComponents
in class Analyzer
fieldName
- the name of the fields content passed to the
Analyzer.TokenStreamComponents
sink as a readerAnalyzer.TokenStreamComponents
for this analyzer.protected TokenStream normalize(String fieldName, TokenStream in)
Analyzer
TokenStream
in order to apply normalization filters.
The default implementation returns the TokenStream
as-is. This is
used by Analyzer.normalize(String, String)
.Copyright © 2000-2020 Apache Software Foundation. All Rights Reserved.