Class SmartChineseAnalyzer
java.lang.Object
org.apache.lucene.analysis.Analyzer
org.apache.lucene.analysis.cn.smart.SmartChineseAnalyzer
- All Implemented Interfaces:
Closeable
,AutoCloseable
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!
- Since:
- 3.1
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
Atomically loads the DEFAULT_STOP_SET in a lazy fashion once the outer class accesses the static final set the first time.;Nested classes/interfaces inherited from class org.apache.lucene.analysis.Analyzer
Analyzer.ReuseStrategy, Analyzer.TokenStreamComponents
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final String
private static final String
private final CharArraySet
Fields inherited from class org.apache.lucene.analysis.Analyzer
GLOBAL_REUSE_STRATEGY, PER_FIELD_REUSE_STRATEGY
-
Constructor Summary
ConstructorsConstructorDescriptionCreate 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 providedSet
of stopwords. -
Method Summary
Modifier and TypeMethodDescriptioncreateComponents
(String fieldName) Creates a newAnalyzer.TokenStreamComponents
instance for this analyzer.static CharArraySet
Returns an unmodifiable instance of the default stop-words set.protected TokenStream
normalize
(String fieldName, TokenStream in) Wrap the givenTokenStream
in order to apply normalization filters.Methods inherited from class org.apache.lucene.analysis.Analyzer
attributeFactory, close, getOffsetGap, getPositionIncrementGap, getReuseStrategy, initReader, initReaderForNormalization, normalize, tokenStream, tokenStream
-
Field Details
-
stopWords
-
DEFAULT_STOPWORD_FILE
- See Also:
-
STOPWORD_FILE_COMMENT
- See Also:
-
-
Constructor Details
-
SmartChineseAnalyzer
public SmartChineseAnalyzer()Create a new SmartChineseAnalyzer, using the default stopword list. -
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!
- Parameters:
useDefaultStopWords
- true to use the default stopword list.
-
SmartChineseAnalyzer
Create a new SmartChineseAnalyzer, using the providedSet
of stopwords.Note: the set should include punctuation, unless you want to index punctuation!
- Parameters:
stopWords
-Set
of stopwords to use.
-
-
Method Details
-
getDefaultStopSet
Returns an unmodifiable instance of the default stop-words set.- Returns:
- an unmodifiable instance of the default stop-words set.
-
createComponents
Description copied from class:Analyzer
Creates a newAnalyzer.TokenStreamComponents
instance for this analyzer.- Specified by:
createComponents
in classAnalyzer
- Parameters:
fieldName
- the name of the fields content passed to theAnalyzer.TokenStreamComponents
sink as a reader- Returns:
- the
Analyzer.TokenStreamComponents
for this analyzer.
-
normalize
Description copied from class:Analyzer
Wrap the givenTokenStream
in order to apply normalization filters. The default implementation returns theTokenStream
as-is. This is used byAnalyzer.normalize(String, String)
.
-