/*******************************************************************************
 * Copyright 2017
 * Language Technology Lab
 * University of Duisburg-Essen
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ******************************************************************************/
package de.unidue.ltl.evaluation.measure;

import static org.junit.Assert.assertEquals;

import java.util.ArrayList;
import java.util.Collection;

import org.junit.Test;

import de.unidue.ltl.evaluation.EvaluationData;
import de.unidue.ltl.evaluation.EvaluationEntry;
import de.unidue.ltl.evaluation.measure.agreement.CohenKappa;
import de.unidue.ltl.evaluation.measure.agreement.FleissKappa;
import de.unidue.ltl.evaluation.measure.agreement.KrippendorffAlpha;
import de.unidue.ltl.evaluation.measure.agreement.LinearlyWeightedKappa;
import de.unidue.ltl.evaluation.measure.agreement.QuadraticallyWeightedKappa;
import de.unidue.ltl.evaluation.measure.agreement.RandolphKappa;
import de.unidue.ltl.evaluation.measure.agreement.ScottPi;
import de.unidue.ltl.evaluation.util.TestUtils;

public class AgreementTest {
	
	@Test
	public void agreementTest(){
		Collection<EvaluationEntry<String>> entries = new ArrayList<EvaluationEntry<String>>();
		entries.add(new EvaluationEntry<String>("A", "B"));
		entries.add(new EvaluationEntry<String>("B", "B"));
		entries.add(new EvaluationEntry<String>("A", "A"));
		entries.add(new EvaluationEntry<String>("A", "A"));
		EvaluationData<String> data = new EvaluationData<>(entries);
		
		assertEquals(0.5, new CohenKappa<String>(data).getAgreement(), 0.001);
		assertEquals(0.533, new KrippendorffAlpha<String>(data).getAgreement(), 0.001);
				
	}
	
	@Test
    public void kappaTest(){
        EvaluationData<Double> entries = new EvaluationData<>(TestUtils.getExampleNumeric());
        
        assertEquals(0.3975, new LinearlyWeightedKappa<Double>(entries).getAgreement(), 0.001);
        assertEquals(0.3492, new QuadraticallyWeightedKappa<Double>(entries).getAgreement(), 0.001);
        assertEquals(0.4523, new FleissKappa<Double>(entries).getAgreement(), 0.001);
        assertEquals(0.4750, new RandolphKappa<Double>(entries).getAgreement(), 0.001);
        assertEquals(0.4523, new ScottPi<Double>(entries).getAgreement(), 0.001);
    }
}

@@ -1056,16 +1056,76 @@
 nEntry;%0A
+import de.unidue.ltl.evaluation.measure.agreement.BennettS;%0A
 import d
@@ -2827,20 +2827,103 @@
 (), 0.001);%0A
+        assertEquals(0.4750, new BennettS%3CDouble%3E(entries).getAgreement(), 0.001);%0A
     %7D%0A%7D%0A

test coverage