huaban / jieba-analysis

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

Keyword 61行未对tfidfvalue相等的情况做判断 #96

Open Wang-Kowah opened 5 years ago

Wang-Kowah commented 5 years ago
@Override
public int compareTo(Keyword o)
{
    return this.tfidfvalue-o.tfidfvalue>0?-1:1;
}

JDK.1.8下,当两个关键词的tfidfvalue相等时会抛出异常IllegalArgumentException: Comparison method violates its general contract! 按照以下方式改写即可:

@Override
public int compareTo(Keyword o)
{
    return this.tfidfvalue - o.tfidfvalue > 0 ? -1 : (this.tfidfvalue == o.tfidfvalue ? 0 : 1);
}