package edu.umass.ciir.galagotools.galago;

import org.lemurproject.galago.core.eval.QueryJudgments;
import org.lemurproject.galago.core.eval.QueryResults;
import org.lemurproject.galago.core.eval.QuerySetJudgments;
import org.lemurproject.galago.core.eval.metric.QueryEvaluator;
import org.lemurproject.galago.core.eval.metric.QueryEvaluatorFactory;
import org.lemurproject.galago.core.retrieval.ScoredDocument;
import org.lemurproject.galago.utility.Parameters;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author jfoley
 */
public class EasyEval {
  public static Map<String,Double> eval(QuerySetJudgments qsj, String qid, List<ScoredDocument> docs, List<String> metrics) {
    HashMap<String,Double> metricValues = new HashMap<>();
    assert(qsj.containsKey(qid));
    assert(!metrics.isEmpty());
    final QueryJudgments qj = qsj.get(qid);
    final QueryResults qres = new QueryResults(qid, docs);
    for(String metric : metrics) {
      QueryEvaluator qeval = QueryEvaluatorFactory.create(metric, Parameters.create());
      double score = qeval.evaluate(qres, qj);
      metricValues.put(metric, score);
    }
    return metricValues;
  }

  public static double singleQuery(List<ScoredDocument> results, String qid, QuerySetJudgments qrels, String metric) {
    QueryResults res = new QueryResults(qid, results);
    QueryEvaluator evaluator = QueryEvaluatorFactory.create(metric, Parameters.create());
    return evaluator.evaluate(res, qrels.get(qid));
  }
}

@@ -37,16 +37,106 @@
 alago;%0A%0A
+import com.google.common.collect.Lists;%0Aimport org.lemurproject.galago.core.eval.EvalDoc;%0A
 import o
@@ -1021,13 +1021,42 @@
 id, 
+Lists.%3CEvalDoc%3EnewArrayList(
 docs)
+)
 ;%0A  
@@ -1466,16 +1466,44 @@
 id, 
+Lists.%3CEvalDoc%3EnewArrayList(
 results)
 ;%0A  
@@ -1498,16 +1498,17 @@
 results)
+)
 ;%0A    Qu

Fix build with new separate galago-eval