优化词前置判断逻辑;
This commit is contained in:
parent
f9bc7a12fa
commit
f173925dc0
|
@ -80,17 +80,16 @@ class CJKSegmenter implements ISegmenter {
|
||||||
// *********************************
|
// *********************************
|
||||||
// 再对当前指针位置的字符进行单字匹配
|
// 再对当前指针位置的字符进行单字匹配
|
||||||
Hit singleCharHit = Dictionary.getSingleton().matchInMainDict(context.getSegmentBuff(), context.getCursor(), 1);
|
Hit singleCharHit = Dictionary.getSingleton().matchInMainDict(context.getSegmentBuff(), context.getCursor(), 1);
|
||||||
if (singleCharHit.isMatch()) {// 首字成词
|
|
||||||
|
// 首字为词前缀
|
||||||
|
if (singleCharHit.isMatch()) {
|
||||||
// 输出当前的词
|
// 输出当前的词
|
||||||
Lexeme newLexeme = new Lexeme(context.getBufferOffset(), context.getCursor(), 1, Lexeme.TYPE_CNWORD);
|
Lexeme newLexeme = new Lexeme(context.getBufferOffset(), context.getCursor(), 1, Lexeme.TYPE_CNWORD);
|
||||||
context.addLexeme(newLexeme);
|
context.addLexeme(newLexeme);
|
||||||
|
}
|
||||||
|
|
||||||
// 同时也是词前缀
|
// 前缀匹配则放入hit列表
|
||||||
if (singleCharHit.isPrefix()) {
|
if (singleCharHit.isPrefix()) {
|
||||||
// 前缀匹配则放入hit列表
|
|
||||||
this.tmpHits.add(singleCharHit);
|
|
||||||
}
|
|
||||||
} else if (singleCharHit.isPrefix()) {// 首字为词前缀
|
|
||||||
// 前缀匹配则放入hit列表
|
// 前缀匹配则放入hit列表
|
||||||
this.tmpHits.add(singleCharHit);
|
this.tmpHits.add(singleCharHit);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue