Skip to content

Commit

Permalink
Merge PR infinilabs#835
Browse files Browse the repository at this point in the history
  • Loading branch information
livelxw committed Dec 9, 2020
1 parent 125ac3c commit 00a39bb
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/main/java/org/wltea/analyzer/core/AnalyzeContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,7 @@

import java.io.IOException;
import java.io.Reader;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map;
import java.util.Set;
import java.util.*;

import org.wltea.analyzer.cfg.Configuration;
import org.wltea.analyzer.dic.Dictionary;
Expand Down Expand Up @@ -72,7 +68,7 @@ class AnalyzeContext {
//LexemePath位置索引表
private Map<Integer , LexemePath> pathMap;
//最终分词结果集
private LinkedList<Lexeme> results;
private TreeSet<Lexeme> results;
//分词器配置项
private Configuration cfg;

Expand All @@ -83,7 +79,7 @@ public AnalyzeContext(Configuration configuration){
this.buffLocker = new HashSet<String>();
this.orgLexemes = new QuickSortSet();
this.pathMap = new HashMap<Integer , LexemePath>();
this.results = new LinkedList<Lexeme>();
this.results = new TreeSet<Lexeme>();
}

int getCursor(){
Expand Down Expand Up @@ -361,7 +357,7 @@ private void compound(Lexeme result){
if(!this.results.isEmpty()){

if(Lexeme.TYPE_ARABIC == result.getLexemeType()){
Lexeme nextLexeme = this.results.peekFirst();
Lexeme nextLexeme = this.results.first();
boolean appendOk = false;
if(Lexeme.TYPE_CNUM == nextLexeme.getLexemeType()){
//合并英文数词+中文数词
Expand All @@ -378,7 +374,7 @@ private void compound(Lexeme result){

//可能存在第二轮合并
if(Lexeme.TYPE_CNUM == result.getLexemeType() && !this.results.isEmpty()){
Lexeme nextLexeme = this.results.peekFirst();
Lexeme nextLexeme = this.results.first();
boolean appendOk = false;
if(Lexeme.TYPE_COUNT == nextLexeme.getLexemeType()){
//合并中文数词+中文量词
Expand Down

0 comments on commit 00a39bb

Please sign in to comment.