edu.cmu.sv.utils.EvaluationTools Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of yoda Show documentation
Show all versions of yoda Show documentation
A library that allows rapid prototyping of dialog systems (language understanding, discourse modelling, dialog management, language generation).
package edu.cmu.sv.utils;
import org.apache.commons.lang3.tuple.Pair;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Created by David Cohen on 9/12/14.
*/
public class EvaluationTools {
public static class ConfusionCounter{
Map> matrixContent;
public ConfusionCounter(List> confusionList){
matrixContent = new HashMap<>();
for (Pair confusion : confusionList){
if (confusion==null)
continue;
if (!matrixContent.containsKey(confusion.getKey()))
matrixContent.put(confusion.getKey(), new HashMap<>());
if (!matrixContent.get(confusion.getKey()).containsKey(confusion.getValue()))
matrixContent.get(confusion.getKey()).put(confusion.getValue(),0);
matrixContent.get(confusion.getKey()).put(
confusion.getValue(),
matrixContent.get(confusion.getKey()).get(confusion.getValue()) + 1);
}
}
@Override
public String toString() {
String ans = "";
for (T key : matrixContent.keySet()){
ans += key + " -> " + matrixContent.get(key) + "\n";
}
return ans;
}
}
}