We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
老哥,JDK7+以上排序算法不是快排,是timsort算法,需要考虑两个值相等的情况 否则会抛出Comparison method violates its general contract!异常
将tfidfvalue换为包装类型,使用包装类型的compareTo方法 解决方案如下: public Keyword(String name, Double tfidfvalue) { this.name = name; // tfidf值只保留3位小数 this.tfidfvalue = Double.valueOf((double)Math.round(tfidfvalue * 10000) / 10000); }
/** * 为了在返回tdidf分析结果时,可以按照值的从大到小顺序返回,故实现Comparable接口 */ @Override public int compareTo(Keyword o) { return o.tfidfvalue.compareTo(this.tfidfvalue); }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
老哥,JDK7+以上排序算法不是快排,是timsort算法,需要考虑两个值相等的情况
否则会抛出Comparison method violates its general contract!异常
将tfidfvalue换为包装类型,使用包装类型的compareTo方法
解决方案如下:
public Keyword(String name, Double tfidfvalue) {
this.name = name;
// tfidf值只保留3位小数
this.tfidfvalue = Double.valueOf((double)Math.round(tfidfvalue * 10000) / 10000);
}
The text was updated successfully, but these errors were encountered: