package org.aksw.limes.core.evaluation;

import static org.junit.Assert.*;

import java.util.List;
import java.util.Map;
import java.util.Set;

import org.aksw.limes.core.datastrutures.TaskAlgorithm;
import org.aksw.limes.core.datastrutures.TaskData;
import org.aksw.limes.core.datastrutures.evaluationRun;
import org.aksw.limes.core.evaluation.evaluator.Evaluator;
import org.aksw.limes.core.evaluation.evaluator.EvaluatorType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.junit.Test;

import com.google.common.collect.Table;

public class EvaluatorsTest {
    static Logger logger = LoggerFactory.getLogger(EvaluatorsTest.class);


    final private String[] datasetsList = {"RESTAURANTS"/*,"PERSON1",  "PERSON2", "PERSON1_CSV", "PERSON2_CSV", "OAEI2014BOOKS"*/};
    final private String[] algorithmsListData = {"UNSUPERVISED:WOMBATSIMPLE"/*,"SUPERVISED_BATCH:WOMBATSIMPLE","SUPERVISED_ACTIVE:WOMBATSIMPLE","UNSUPERVISED:WOMBATCOMPLETE","SUPERVISED_BATCH:WOMBATCOMPLETE"*/};

    private static final int folds=5;
    private static final boolean crossValidate=false; 

    @Test
    public void test() {
        /*        if(crossValidate)
            testCrossValidate();
        else*/
        testEvaluator();
    }
    public void testEvaluator() {
        try {

            DatasetsInitTest ds = new DatasetsInitTest();
            EvaluatorsInitTest ev = new EvaluatorsInitTest();
            AlgorithmsInitTest al = new AlgorithmsInitTest();
            Evaluator evaluator = new Evaluator();

            Set<TaskData> tasks = ds.initializeDataSets(datasetsList);
            Set<EvaluatorType> evaluators = ev.initializeEvaluators();
            List<TaskAlgorithm> algorithms = al.initializeMLAlgorithms(algorithmsListData,datasetsList.length);

            List<evaluationRun> results = evaluator.evaluate(algorithms, tasks, evaluators, null);
            for (evaluationRun er : results) {
                er.display();
            }

        } catch (Exception e) {
            System.out.println(e.getMessage());
            assertTrue(false);
        }
        assertTrue(true);
    }


    public void testCrossValidate() {
        try {

            DatasetsInitTest ds = new DatasetsInitTest();
            EvaluatorsInitTest ev = new EvaluatorsInitTest();
            AlgorithmsInitTest al = new AlgorithmsInitTest();
            Evaluator evaluator = new Evaluator();

            Set<TaskData> tasks = ds.initializeDataSets(datasetsList);
            Set<EvaluatorType> evaluators = ev.initializeEvaluators();
            List<TaskAlgorithm> algorithms = al.initializeMLAlgorithms(algorithmsListData,datasetsList.length);
            List<evaluationRun> results =null;
            for (TaskAlgorithm tAlgorithm : algorithms) {
                results = evaluator.crossValidate(tAlgorithm.getMlAlgorithm(), tasks,folds, evaluators, null);
            }
            for (evaluationRun er : results) {
                er.display();
            }
            /*for (TaskAlgorithm tAlgorithm : algorithms) {
                Table<String, String, Map<EvaluatorType, Double>> results = evaluator.crossValidate(tAlgorithm.getMlAlgorithm(), tasks,folds, evaluators, null);

            }*/

        } catch (Exception e) {
            System.out.println(e.getMessage());
            assertTrue(false);
        }
        assertTrue(true);
    }


}

@@ -285,17 +285,17 @@
 rutures.
-e
+E
 valuatio
@@ -1786,33 +1786,33 @@
            List%3C
-e
+E
 valuationRun%3E re
@@ -1885,33 +1885,33 @@
            for (
-e
+E
 valuationRun er 
@@ -1966,16 +1966,117 @@
        %7D
+%0A            for (EvaluationRun er : results) %7B%0A                System.out.println(er);%0A            %7D
 %0A%0A      
@@ -2782,17 +2782,17 @@
    List%3C
-e
+E
 valuatio
@@ -3012,17 +3012,17 @@
    for (
-e
+E
 valuatio

fix some javadoc minor errors