in opennlp-tools/src/main/java/opennlp/tools/cmdline/FineGrainedReportListener.java [621:673]
public int compare(String o1, String o2) {
if (o1.equals(o2)) {
return 0;
}
String c1 = o1;
String c2 = o2;
if (o1.contains("-")) {
c1 = o1.split("-")[0];
}
if (o2.contains("-")) {
c2 = o2.split("-")[0];
}
if (c1.equals(c2)) { // same category - sort by confusion matrix
Counter t1 = labelCounter.get(o1);
Counter t2 = labelCounter.get(o2);
if (t1 == null || t2 == null) {
if (t1 == null) {
return 1;
} else {
return -1;
}
}
int r1 = t1.value();
int r2 = t2.value();
if (r1 == r2) {
return o1.compareTo(o2);
}
if (r2 > r1) {
return 1;
}
return -1;
} else { // different category - sort by category
Integer t1 = categoryCounter.get(c1);
Integer t2 = categoryCounter.get(c2);
if (t1 == null || t2 == null) {
if (t1 == null) {
return 1;
} else {
return -1;
}
}
if (t1.equals(t2)) {
return o1.compareTo(o2);
}
if (t2 > t1) {
return 1;
}
return -1;
}
}