/*******************************************************************************
 * Copyright 2013
 * Ubiquitous Knowledge Processing (UKP) Lab
 * Technische Universität Darmstadt
 * 
 * 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.tudarmstadt.ukp.dkpro.statistics.unitizing;

import static org.junit.Assert.assertEquals;

import org.junit.Before;
import org.junit.Test;

public class AlphaUnitizedAgreementTest
{

    private AlphaUnitizedAgreement alphaForKrippendorfStudy;

    @Before
    public void setUp()
    {
        final UnitizingStudy study = StudyFactory.getKrippendorfSampleStudy();
        this.alphaForKrippendorfStudy = new AlphaUnitizedAgreement(study);
    }

    @Test
    public void testAlphaUnitizedAgreementObservedDisagreement()
    {
        assertEquals(0.0144, alphaForKrippendorfStudy.getObservedDisagreement("c"), 0.0001);
        assertEquals(0.0, alphaForKrippendorfStudy.getObservedDisagreement("k"), 0.0);
    }

    @Test
    public void testAlphaUnitizedAgreementExpectedDisagreement()
    {
        assertEquals(0.0532, alphaForKrippendorfStudy.getExpectedDisagreement("c"), 0.0001);
        assertEquals(0.0490, alphaForKrippendorfStudy.getExpectedDisagreement("k"), 0.0001);
    }

    @Test
    public void testAlphaUnitizedCategoryAgreement()
    {
        // The expected value differs from the value
        // of Krippendorf's paper because there
        // all values are rounded to 4 decimal places
        assertEquals(0.7285, alphaForKrippendorfStudy.estimateCategoryAgreement("c"), 0.0001);
        assertEquals(1.0, alphaForKrippendorfStudy.estimateCategoryAgreement("k"), 0.0001);
    }

    @Test
    public void testAlphaUnitizedJointAgreement()
    {
        // The expected value differs from the value
        // of Krippendorf's paper because there
        // all values are rounded to 4 decimal places
        assertEquals(0.8587, alphaForKrippendorfStudy.estimateJointAgreement(), 0.0001);

    }
}

@@ -911,16 +911,59 @@
 tEquals;
+%0Aimport static org.junit.Assert.assertTrue;
 %0A%0Aimport
@@ -1005,16 +1005,74 @@
 .Test;%0A%0A
+/**%0A * Unit tests for %7B@link AlphaUnitizedAgreement%7D %0A */%0A
 public c
@@ -1481,16 +1481,21 @@
 0.0144, 
+this.
 alphaFor
@@ -1572,24 +1572,29 @@
 Equals(0.0, 
+this.
 alphaForKrip
@@ -1759,16 +1759,21 @@
 0.0532, 
+this.
 alphaFor
@@ -1857,16 +1857,21 @@
 0.0490, 
+this.
 alphaFor
@@ -2186,16 +2186,21 @@
 0.7285, 
+this.
 alphaFor
@@ -2283,16 +2283,21 @@
 ls(1.0, 
+this.
 alphaFor
@@ -2611,16 +2611,21 @@
 0.8587, 
+this.
 alphaFor
@@ -2682,11 +2682,383 @@
 ;%0A%0A    %7D
+%0A%0A    @Test%0A    public void testOnlyOneAnnotation()%0A    %7B%0A        final UnitizingStudy study = new UnitizingStudy(3);%0A        study.addSection(%22X%22, 0, 1, 1);%0A        study.setContinuumLength(20);%0A        study.close();%0A%0A        final AlphaUnitizedAgreement agreement = new AlphaUnitizedAgreement(study);%0A%0A        assertTrue(agreement.estimateJointAgreement() %3C 1.0);%0A    %7D
 %0A%7D%0A

Add failing test case for Issue 2