huaban / jieba-analysis

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

Keyword比较器在jdk7以上的情况下会报错 #133

Open 15797620308 opened 2 years ago

15797620308 commented 2 years ago

public int compareTo(Keyword o) { return this.tfidfvalue - o.tfidfvalue > 0.0D ? -1 : 1; } 这段代码在jdk7以上会违反Comparator三大原则:自反性,传递性,对称性,所以强烈建议将此处代码进行修改 参考如下,以下代码做个测试,可行: public int compareTo(Keyword o) { return Double.compare(o.tfidfvalue, this.tfidfvalue); }

corgy-w commented 2 years ago

都停更这么久了 。

linshouyi commented 1 year ago

确实有这个问题。