Skip to content

Commit

Permalink
Merge pull request ysc#47 from niexiaolong/patch-1
Browse files Browse the repository at this point in the history
全切分实现修改
  • Loading branch information
ysc authored Oct 13, 2017
2 parents 66647fd + 337dae9 commit ac6ad2f
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,11 @@ public List<Word> segImpl(String text) {
}
//获取全切分结果
List<Word>[] array = fullSeg(text);
//利用ngram计算分值
Map<List<Word>, Float> words = ngram(array);
//歧义消解(ngram分值优先、词个数少优先)
List<Word> result = disambiguity(words);
Set<Word> words = new HashSet<Word>();
for(List<Word> wordList : array){
words.addAll(wordList);
}
List<Word> result = new ArrayList<Word>(words);
return result;
}
private List<Word> disambiguity(Map<List<Word>, Float> words){
Expand Down Expand Up @@ -284,4 +285,4 @@ public static void main(String[] args){
String text = "蝶舞打扮得漂漂亮亮出现在张公公面前";
System.out.println(m.seg(text));
}
}
}

0 comments on commit ac6ad2f

Please sign in to comment.