Skip to content

Commit 9873489

Browse files
authored
Update AnalyzeContext.java
使用ik_smart切分 金力泰合同审批 切分的结果是(金 力 泰 合同 审批)但是使用ik_max_word切分结果是(金 力 泰合 合同 审批 批),这样就存在搜索(金力泰 金力泰合同审批) 搜索不到的情况,查看源码发现泰未在字典中,泰合 合同在字典中,导致smart切分消歧的时候按照逆向概率高的规则忽略了泰合,输出结果泰就单独切分了,可以在输出结果时判断下 字典中无单字,但是词元冲突了,切分出相交词元的前一个词元中的单字,这样就能解决这个问题
1 parent 9495315 commit 9873489

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/main/java/org/wltea/analyzer/core/AnalyzeContext.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,15 @@ void outputToResult(){
267267
Lexeme l = path.pollFirst();
268268
while(l != null){
269269
this.results.add(l);
270+
//字典中无单字,但是词元冲突了,切分出相交词元的前一个词元中的单字
271+
int innerIndex = index + 1;
272+
for (; innerIndex < index + l.getLength(); innerIndex++) {
273+
Lexeme innerL = path.peekFirst();
274+
if (innerL != null && innerIndex == innerL.getBegin()) {
275+
this.outputSingleCJK(innerIndex - 1);
276+
}
277+
}
278+
270279
//将index移至lexeme后
271280
index = l.getBegin() + l.getLength();
272281
l = path.pollFirst();

0 commit comments

Comments
 (0)