public abstract class TextAnalyzer extends Object
Modifier and Type | Field and Description |
---|---|
protected String |
dictionaryPath |
protected Map<String,? extends Object> |
keywordDefinitions |
protected TreeMap<Integer,? extends Object> |
lengthDefinitions |
static int |
TYPE_FAST
使用KeywordMatcher与自定义的字典表进行分词(试验中,尚不完善)
|
static int |
TYPE_MMSEG_COMPLEX
使用com.chenlb.mmseg4j.ComplexSeg进行分词
|
static int |
TYPE_MMSEG_MAXWORD
使用com.chenlb.mmseg4j.MaxWordSeg进行分词
|
static int |
TYPE_MMSEG_SIMPLE
使用com.chenlb.mmseg4j.SimpleSeg进行分词
|
Modifier | Constructor and Description |
---|---|
protected |
TextAnalyzer(String dictionaryPath,
Map<String,? extends Object> keywordDefinitions,
Map<Integer,? extends Object> lengthDefinitions)
Constructor that will be used internally.
仅供内部使用的构造方法。 |
Modifier and Type | Method and Description |
---|---|
AnalyzedText |
analyze(String text)
对文本进行立刻分析,不用lazy方式。
|
AnalyzedText |
analyze(String text,
boolean lazy)
对文本进行分析。
|
static TextAnalyzer |
createInstance(int type)
Create an instance of TextAnalyzer.
创建一个文本分析器实例。 |
static TextAnalyzer |
createInstance(int type,
Map<String,? extends Object> keywordDefinitions,
Map<Integer,? extends Object> lengthDefinitions)
Create an instance of TextAnalyzer.
创建一个文本分析器实例。 |
static TextAnalyzer |
createInstance(int type,
String dictionaryPath,
Map<String,? extends Object> keywordDefinitions,
Map<Integer,? extends Object> lengthDefinitions)
Create an instance of TextAnalyzer.
创建一个文本分析器实例。 |
public static final int TYPE_MMSEG_SIMPLE
public static final int TYPE_MMSEG_MAXWORD
public static final int TYPE_MMSEG_COMPLEX
public static final int TYPE_FAST
protected String dictionaryPath
protected TextAnalyzer(String dictionaryPath, Map<String,? extends Object> keywordDefinitions, Map<Integer,? extends Object> lengthDefinitions)
dictionaryPath
- 字典文件路径keywordDefinitions
- 关键词字的定义lengthDefinitions
- 文本长度类别定义public static TextAnalyzer createInstance(int type, String dictionaryPath, Map<String,? extends Object> keywordDefinitions, Map<Integer,? extends Object> lengthDefinitions)
type
- TYPE_MMSEG_SIMPLE
| TYPE_MMSEG_COMPLEX
| TYPE_MMSEG_MAXWORD
| TYPE_FAST
dictionaryPath
- 字典文件路径,如果为null,则表示使用缺省位置的字典文件keywordDefinitions
- 关键词字的定义lengthDefinitions
- 文本长度类别定义public static TextAnalyzer createInstance(int type, Map<String,? extends Object> keywordDefinitions, Map<Integer,? extends Object> lengthDefinitions)
type
- TYPE_MMSEG_SIMPLE
| TYPE_MMSEG_COMPLEX
| TYPE_MMSEG_MAXWORD
| TYPE_FAST
keywordDefinitions
- 关键词字的定义lengthDefinitions
- 文本长度类别定义public static TextAnalyzer createInstance(int type)
type
- TYPE_MMSEG_SIMPLE
| TYPE_MMSEG_COMPLEX
| TYPE_MMSEG_MAXWORD
| TYPE_FAST
public AnalyzedText analyze(String text, boolean lazy)
text
- 待分析的文本lazy
- 是否延迟分析(所谓延迟是指直到用到分析结果的时候才进行实质性分析)public AnalyzedText analyze(String text)
text
- 待分析的文本Copyright © 2014. All Rights Reserved.