public abstract class AbstractSegmentation extends Object implements Segmentation
限定符和类型 | 字段和说明 |
---|---|
protected static Dictionary |
DIC |
protected static boolean |
KEEP_PUNCTUATION |
protected static boolean |
KEEP_WHITESPACE |
protected static org.slf4j.Logger |
LOGGER |
protected static boolean |
PERSON_NAME_RECOGNIZE |
构造器和说明 |
---|
AbstractSegmentation() |
限定符和类型 | 方法和说明 |
---|---|
protected void |
addWord(List<Word> result,
String text,
int start,
int len)
将识别出的词放入队列
|
protected void |
addWord(Stack<Word> result,
String text,
int start,
int len)
将识别出的词入栈
|
int |
getInterceptLength()
分词时截取的字符串的最大长度
|
protected Word |
getWord(String text,
int start,
int len)
获取一个已经识别的词
|
protected boolean |
isWhiteSpace(char c)
判断指定的字符是否是空白字符
|
protected boolean |
isWhiteSpace(String text,
int start,
int len)
判断索引下标为start的字符是否为空白字符
这个方法只用在这里
为了速度,不检查索引下标是否越界
|
static void |
main(String[] args) |
Map<List<Word>,Float> |
ngram(List<Word>... sentences)
利用ngram进行评分
|
boolean |
ngramEnabled()
是否启用ngram
|
List<Word> |
seg(String text)
默认分词算法实现:
1、把要分词的文本根据标点符号进行分割
2、对分割后的文本进行分词
3、组合分词结果
|
abstract List<Word> |
segImpl(String text) |
protected static final org.slf4j.Logger LOGGER
protected static final Dictionary DIC
protected static final boolean PERSON_NAME_RECOGNIZE
protected static final boolean KEEP_WHITESPACE
protected static final boolean KEEP_PUNCTUATION
public boolean ngramEnabled()
public Map<List<Word>,Float> ngram(List<Word>... sentences)
sentences
- 多个分词结果public int getInterceptLength()
public List<Word> seg(String text)
seg
在接口中 Segmentation
text
- 文本protected void addWord(List<Word> result, String text, int start, int len)
result
- 队列text
- 文本start
- 词开始索引len
- 词长度protected void addWord(Stack<Word> result, String text, int start, int len)
result
- 栈text
- 文本start
- 词开始索引len
- 词长度protected Word getWord(String text, int start, int len)
text
- 文本start
- 词开始索引len
- 词长度protected boolean isWhiteSpace(String text, int start, int len)
text
- 文本start
- 索引下标len
- 长度protected boolean isWhiteSpace(char c)
c
- 字符public static void main(String[] args)
Copyright © 2014 APDPlat. All rights reserved.