public final class SmartChineseAnalyzer extends Analyzer
SmartChineseAnalyzer is an analyzer for Chinese or mixed Chinese-English text. The analyzer uses probabilistic knowledge to find the optimal word segmentation for Simplified Chinese text. The text is first broken into sentences, then each sentence is segmented into words.
Segmentation is based upon the Hidden Markov Model. A large training corpus was used to calculate Chinese word frequency probability.
This analyzer requires a dictionary to provide statistical data. SmartChineseAnalyzer has an included dictionary out-of-box.
The included dictionary data is from ICTCLAS1.0. Thanks to ICTCLAS for their hard work, and for contributing the data under the Apache 2 License!
Analyzer.ReuseStrategy, Analyzer.TokenStreamComponents
GLOBAL_REUSE_STRATEGY, PER_FIELD_REUSE_STRATEGY
Constructor and Description |
---|
SmartChineseAnalyzer()
Create a new SmartChineseAnalyzer, using the default stopword list.
|
SmartChineseAnalyzer(boolean useDefaultStopWords)
Create a new SmartChineseAnalyzer, optionally using the default stopword list.
|
SmartChineseAnalyzer(CharArraySet stopWords)
Create a new SmartChineseAnalyzer, using the provided
Set of stopwords. |
Modifier and Type | Method and Description |
---|---|
Analyzer.TokenStreamComponents |
createComponents(String fieldName) |
static CharArraySet |
getDefaultStopSet()
Returns an unmodifiable instance of the default stop-words set.
|
protected TokenStream |
normalize(String fieldName,
TokenStream in) |
attributeFactory, close, getOffsetGap, getPositionIncrementGap, getReuseStrategy, getVersion, initReader, initReaderForNormalization, normalize, setVersion, tokenStream, tokenStream
public SmartChineseAnalyzer()
public SmartChineseAnalyzer(boolean useDefaultStopWords)
Create a new SmartChineseAnalyzer, optionally using the default stopword list.
The included default stopword list is simply a list of punctuation. If you do not use this list, punctuation will not be removed from the text!
useDefaultStopWords
- true to use the default stopword list.public SmartChineseAnalyzer(CharArraySet stopWords)
Create a new SmartChineseAnalyzer, using the provided Set
of stopwords.
Note: the set should include punctuation, unless you want to index punctuation!
stopWords
- Set
of stopwords to use.public static CharArraySet getDefaultStopSet()
public Analyzer.TokenStreamComponents createComponents(String fieldName)
createComponents
in class Analyzer
protected TokenStream normalize(String fieldName, TokenStream in)
Copyright © 2000-2021 Apache Software Foundation. All Rights Reserved.