int i = 1;
int dupliCount = 0;
double rsvPrev = 0;
for (TResultComparable sortedResult : sortedResults) {
TResult result = sortedResult.getTResult();
double rsvCurr = result.rsv;
if (Math.abs(rsvCurr - rsvPrev) > 0.0000001) {
dupliCount = 0;
} else {
dupliCount ++;
rsvCurr = rsvCurr - 0.000001 / numResults * dupliCount;
}
// The TREC official qrels don't have the "MB" prefix and trailing zeros, so we perform
// this transformation so that trec_eval doesn't complain.
String qid = query.getId().replaceFirst("^MB0*", "");
out.println(String.format("%s Q0 %d %d %." + (int) (6 + Math.ceil(Math.log10(numResults))) + "f %s",
qid, result.id, i, rsvCurr, runtag));
if (verbose) {
out.println("# " + result.toString().replaceAll("[\\n\\r]+", " "));
}
i++;
rsvPrev = result.rsv;
}