// Path: dkpro-statistics-agreement/src/main/java/org/dkpro/statistics/agreement/IAnnotationStudy.java
// public interface IAnnotationStudy
//     extends Serializable
// {
// 
//     // -- Raters --
// 
//     /** Returns the number of raters participating in this study. */
//     int getRaterCount();
//     
//     int findRater(final String name);
// 
//     // -- Categories --
// 
//     /**
//      * Returns an iterator over all annotation categories within the study. Note that the categories
//      * are not per se clear; they might need to be gathered by iterating through all associated
//      * items, which yields performance problems in large-scale annotation studies.
//      */
//     Iterable<Object> getCategories();
// 
//     /**
//      * Returns the number of annotation categories in the study. Note that the categories are not
//      * per se clear; they might need to be gathered by iterating through all associated items, which
//      * yields performance problems in large-scale annotation studies.
//      */
//     int getCategoryCount();
// 
//     /**
//      * Returns true if, and only if, the categories defined by the study yield a dichotomy (i.e.,
//      * there are exactly two categories).
//      */
//     boolean isDichotomous();
// 
//     // -- Units --
// 
//     // public Iterable<? extends IAnnotationUnit> getUnits();
// 
//     /**
//      * Returns the number of annotation units defined by the study. That is, the number of
//      * annotations coded by the raters.
//      */
//     int getUnitCount();
// }
// 
// Path: dkpro-statistics-agreement/src/main/java/org/dkpro/statistics/agreement/distance/IDistanceFunction.java
// public interface IDistanceFunction
// {
// 
//     /**
//      * Returns a distance value for the given pair of categories used within the given annotation
//      * study. Normally, the measure should return a distance of 0 if, and only if, the two
//      * categories are equal and a positive number otherwise.
//      */
//     public double measureDistance(final IAnnotationStudy study, final Object category1,
//             final Object category2);
// 
// }
// 
// Path: dkpro-statistics-agreement/src/main/java/org/dkpro/statistics/agreement/distance/NominalDistanceFunction.java
// public class NominalDistanceFunction
//     implements IDistanceFunction
// {
// 
//     @Override
//     public double measureDistance(final IAnnotationStudy study, final Object category1,
//             final Object category2)
//     {
//         return (category1.equals(category2) ? 0.0 : 1.0);
//     }
// 
// }


import static junit.framework.Assert.assertEquals;
import org.dkpro.statistics.agreement.IAnnotationStudy;
import org.dkpro.statistics.agreement.distance.IDistanceFunction;
import org.dkpro.statistics.agreement.distance.NominalDistanceFunction;
import org.junit.Test;

        BennettSAgreement s = new BennettSAgreement(study);
        assertEquals(0.88, s.calculateObservedAgreement(), 0.001);
        assertEquals(0.333, s.calculateExpectedAgreement(), 0.001);
        assertEquals(0.82, s.calculateAgreement(), 0.001);

        ScottPiAgreement pi = new ScottPiAgreement(study);
        assertEquals(0.88, pi.calculateObservedAgreement(), 0.001);
        assertEquals(0.401, pi.calculateExpectedAgreement(), 0.001);
        assertEquals(0.799, pi.calculateAgreement(), 0.001);

        CohenKappaAgreement kappa = new CohenKappaAgreement(study);
        assertEquals(0.88, kappa.calculateObservedAgreement(), 0.001);
        assertEquals(0.396, kappa.calculateExpectedAgreement(), 0.001);
        assertEquals(0.801, kappa.calculateAgreement(), 0.001);
    }

    /*
     * public void testCategoryAgreement() { //TODO positive and negative agreement!
     * ICodingAnnotationStudy study = createExample1();
     * 
     * PercentageAgreement cat = new PercentageAgreement(study); assertEquals(0.571,
     * cat.calculateCategoryAgreement("STAT"), 0.001); assertEquals(0.769,
     * cat.calculateCategoryAgreement("IReq"), 0.001); }
     */

    @Test
    public void testWeightedAgreement()
    {
        ICodingAnnotationStudy study = createExample2();
// Path: dkpro-statistics-agreement/src/main/java/org/dkpro/statistics/agreement/IAnnotationStudy.java
// public interface IAnnotationStudy
//     extends Serializable
// {
// 
//     // -- Raters --
// 
//     /** Returns the number of raters participating in this study. */
//     int getRaterCount();
//     
//     int findRater(final String name);
// 
//     // -- Categories --
// 
//     /**
//      * Returns an iterator over all annotation categories within the study. Note that the categories
//      * are not per se clear; they might need to be gathered by iterating through all associated
//      * items, which yields performance problems in large-scale annotation studies.
//      */
//     Iterable<Object> getCategories();
// 
//     /**
//      * Returns the number of annotation categories in the study. Note that the categories are not
//      * per se clear; they might need to be gathered by iterating through all associated items, which
//      * yields performance problems in large-scale annotation studies.
//      */
//     int getCategoryCount();
// 
//     /**
//      * Returns true if, and only if, the categories defined by the study yield a dichotomy (i.e.,
//      * there are exactly two categories).
//      */
//     boolean isDichotomous();
// 
//     // -- Units --
// 
//     // public Iterable<? extends IAnnotationUnit> getUnits();
// 
//     /**
//      * Returns the number of annotation units defined by the study. That is, the number of
//      * annotations coded by the raters.
//      */
//     int getUnitCount();
// }
// 
// Path: dkpro-statistics-agreement/src/main/java/org/dkpro/statistics/agreement/distance/IDistanceFunction.java
// public interface IDistanceFunction
// {
// 
//     /**
//      * Returns a distance value for the given pair of categories used within the given annotation
//      * study. Normally, the measure should return a distance of 0 if, and only if, the two
//      * categories are equal and a positive number otherwise.
//      */
//     public double measureDistance(final IAnnotationStudy study, final Object category1,
//             final Object category2);
// 
// }
// 
// Path: dkpro-statistics-agreement/src/main/java/org/dkpro/statistics/agreement/distance/NominalDistanceFunction.java
// public class NominalDistanceFunction
//     implements IDistanceFunction
// {
// 
//     @Override
//     public double measureDistance(final IAnnotationStudy study, final Object category1,
//             final Object category2)
//     {
//         return (category1.equals(category2) ? 0.0 : 1.0);
//     }
// 
// }


// Path: dkpro-statistics-agreement/src/test/java/org/dkpro/statistics/agreement/coding/ArtsteinPoesio2008Test.java
import static junit.framework.Assert.assertEquals;
import org.dkpro.statistics.agreement.IAnnotationStudy;
import org.dkpro.statistics.agreement.distance.IDistanceFunction;
import org.dkpro.statistics.agreement.distance.NominalDistanceFunction;
import org.junit.Test;


        BennettSAgreement s = new BennettSAgreement(study);
        assertEquals(0.88, s.calculateObservedAgreement(), 0.001);
        assertEquals(0.333, s.calculateExpectedAgreement(), 0.001);
        assertEquals(0.82, s.calculateAgreement(), 0.001);

        ScottPiAgreement pi = new ScottPiAgreement(study);
        assertEquals(0.88, pi.calculateObservedAgreement(), 0.001);
        assertEquals(0.401, pi.calculateExpectedAgreement(), 0.001);
        assertEquals(0.799, pi.calculateAgreement(), 0.001);

        CohenKappaAgreement kappa = new CohenKappaAgreement(study);
        assertEquals(0.88, kappa.calculateObservedAgreement(), 0.001);
        assertEquals(0.396, kappa.calculateExpectedAgreement(), 0.001);
        assertEquals(0.801, kappa.calculateAgreement(), 0.001);
    }

    /*
     * public void testCategoryAgreement() { //TODO positive and negative agreement!
     * ICodingAnnotationStudy study = createExample1();
     * 
     * PercentageAgreement cat = new PercentageAgreement(study); assertEquals(0.571,
     * cat.calculateCategoryAgreement("STAT"), 0.001); assertEquals(0.769,
     * cat.calculateCategoryAgreement("IReq"), 0.001); }
     */

    @Test
    public void testWeightedAgreement()
    {
        ICodingAnnotationStudy study = createExample2();
        IDistanceFunction weightedDistanceFunction = new IDistanceFunction()