package at.medunigraz.imi.bst.trec.model;

import java.util.Map;
import java.util.Set;
import java.util.TreeMap;

public class Metrics {
	
	private Map<String, Double> metrics = new TreeMap<>();

	public void put(String name, double value) {
		metrics.put(name, value);
	}
	
	public double getMetric(String name) {
		return metrics.getOrDefault(name, 0d);
	}
	
	public String getMetricsAsString() {
		StringBuilder sb = new StringBuilder();
		
		Set<Map.Entry<String, Double>> entries = metrics.entrySet();
		for (Map.Entry<String, Double> entry : entries) {
			sb.append(entry.getKey());
			sb.append("=");
			sb.append(entry.getValue());
			sb.append("\n");
		}
		
		return sb.toString();
	}
}

@@ -687,10 +687,307 @@
 g();%0A%09%7D%0A
+%09%0A%09public double getNDCG() %7B%0A%09%09return getMetric(%22ndcg%22);%0A%09%7D%0A%0A%09public double getRPrec() %7B%0A%09%09return getMetric(%22Rprec%22);%0A%09%7D%0A%0A%09public double getInfAP() %7B%0A%09%09return getMetric(%22infAP%22);%0A%09%7D%0A%0A%09public double getP10() %7B%0A%09%09return getMetric(%22P_10%22);%0A%09%7D%0A%0A%09public double getF() %7B%0A%09%09return getMetric(%22set_F%22);%0A%09%7D%0A
 %7D%0A

Add convenient methods to get some common metrics