All Downloads are FREE. Search and download functionalities are using the official Maven repository.

edu.cmu.sv.utils.EvaluationTools Maven / Gradle / Ivy

Go to download

A library that allows rapid prototyping of dialog systems (language understanding, discourse modelling, dialog management, language generation).

There is a newer version: 0.7.0
Show newest version
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;
        }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy