import org.apache.poi.ss.usermodel.Row; //导入方法依赖的package包/类
/**
* generates the IDCG and nDCG
* @param prec_recall
* @param rowPR
* @param ratings
*/
private static void computeIDCG_nDCG(Sheet prec_recall, Row rowPR, ArrayList ratings) {
CellReference cellRefDCGFirst = new CellReference(1, COLUMN_DCG);
CellReference cellRefDCGLast = new CellReference(50, COLUMN_DCG);
Cell cellPR = rowPR.createCell(COLUMN_DCG);
cellPR.setCellFormula("SUM("+cellRefDCGFirst.formatAsString()
+":"+cellRefDCGLast.formatAsString()+")");
//Get the List of ratings and sort them by relevance (rating)
Collections.sort(ratings, new Comparator() {
@Override
public int compare(Rating o1, Rating o2) {
return Float.compare(o2.rating, o1.rating