huaban / jieba-analysis

结巴分词(java版)
https://github.com/huaban/jieba-analysis
Apache License 2.0
2.55k stars 835 forks source link

在jdk1.8、纯英文文本分词时,出现了IllegalArgumentException: Comparison method violates its general contract!异常,需要自己实现一个Comparator #89

Open WsureDev opened 5 years ago

WsureDev commented 5 years ago

在com.qianxinyao.analysis.jieba.keyword.TFIDFAnalyzer的56行Collections.sort(keywordList);

可以改写成 Collections.sort(keywordList, new Comparator() { @Override public int compare(Keyword o1, Keyword o2) { Double d1 = o1.getTfidfvalue(); Double d2 = o2.getTfidfvalue(); return d2.compareTo(d1); } });