Skip to content

Commit 00a39bb

Browse files
committed
Merge PR infinilabs#835
1 parent 125ac3c commit 00a39bb

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

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

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,7 @@
2626

2727
import java.io.IOException;
2828
import java.io.Reader;
29-
import java.util.HashMap;
30-
import java.util.HashSet;
31-
import java.util.LinkedList;
32-
import java.util.Map;
33-
import java.util.Set;
29+
import java.util.*;
3430

3531
import org.wltea.analyzer.cfg.Configuration;
3632
import org.wltea.analyzer.dic.Dictionary;
@@ -72,7 +68,7 @@ class AnalyzeContext {
7268
//LexemePath位置索引表
7369
private Map<Integer , LexemePath> pathMap;
7470
//最终分词结果集
75-
private LinkedList<Lexeme> results;
71+
private TreeSet<Lexeme> results;
7672
//分词器配置项
7773
private Configuration cfg;
7874

@@ -83,7 +79,7 @@ public AnalyzeContext(Configuration configuration){
8379
this.buffLocker = new HashSet<String>();
8480
this.orgLexemes = new QuickSortSet();
8581
this.pathMap = new HashMap<Integer , LexemePath>();
86-
this.results = new LinkedList<Lexeme>();
82+
this.results = new TreeSet<Lexeme>();
8783
}
8884

8985
int getCursor(){
@@ -361,7 +357,7 @@ private void compound(Lexeme result){
361357
if(!this.results.isEmpty()){
362358

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

379375
//可能存在第二轮合并
380376
if(Lexeme.TYPE_CNUM == result.getLexemeType() && !this.results.isEmpty()){
381-
Lexeme nextLexeme = this.results.peekFirst();
377+
Lexeme nextLexeme = this.results.first();
382378
boolean appendOk = false;
383379
if(Lexeme.TYPE_COUNT == nextLexeme.getLexemeType()){
384380
//合并中文数词+中文量词

0 commit comments

Comments
 (0)