// Path: dkpro-statistics-agreement/src/main/java/org/dkpro/statistics/agreement/AgreementMeasure.java
// public abstract class AgreementMeasure
//     implements IAgreementMeasure
// {
// 
//     @Override
//     public double calculateAgreement()
//     {
//         double A_O = calculateObservedAgreement();
//         double A_E = calculateExpectedAgreement();
//         if (A_E == 0.0) {
//             return A_O;
//         }
//         else if (A_O == 1.0 && A_E == 1.0) {
//             throw new InsufficientDataException(
//                     "Insufficient variation. Most likely, the raters only used a single category which yields an expected agreement of 1.0. In this case, it is not possible to make any statement about the other categories and thus the agreement of the study itself.");
//         }
//         else {
//             return (A_O - A_E) / (1.0 - A_E);
//         }
//     }
// 
//     protected abstract double calculateObservedAgreement();
// 
//     protected double calculateExpectedAgreement()
//     {
//         return 0.0;
//     }
// }
// 
// Path: dkpro-statistics-agreement/src/main/java/org/dkpro/statistics/agreement/InsufficientDataException.java
// public class InsufficientDataException
//     extends RuntimeException
// {
//     private static final long serialVersionUID = -3081535421752493402L;
// 
//     public InsufficientDataException()
//     {
//         super();
//     }
// 
//     public InsufficientDataException(final String message, final Throwable cause)
//     {
//         super(message, cause);
//     }
// 
//     public InsufficientDataException(final String message)
//     {
//         super(message);
//     }
// 
//     public InsufficientDataException(final Throwable cause)
//     {
//         super(cause);
//     }
// }


import java.util.Map;
import org.dkpro.statistics.agreement.AgreementMeasure;
import org.dkpro.statistics.agreement.InsufficientDataException;
/*
 * Copyright 2014
 * 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 org.dkpro.statistics.agreement.coding;



/**
 * Abstract base class of agreement measures for {@link ICodingAnnotationStudy}s.
 * 
 * @author Christian M. Meyer
 */
public abstract class CodingAgreementMeasure
    extends AgreementMeasure
    implements ICodingAgreementMeasure
{
    protected ICodingAnnotationStudy study;

    /**
     * Initializes the instance for the given annotation study. The study should never be null.
     */
    public CodingAgreementMeasure(final ICodingAnnotationStudy study)
    {
        this.study = study;
    }

    @Override
    public double calculateObservedAgreement()
    {
        if (study.getCategoryCount() <= 1) {
// Path: dkpro-statistics-agreement/src/main/java/org/dkpro/statistics/agreement/AgreementMeasure.java
// public abstract class AgreementMeasure
//     implements IAgreementMeasure
// {
// 
//     @Override
//     public double calculateAgreement()
//     {
//         double A_O = calculateObservedAgreement();
//         double A_E = calculateExpectedAgreement();
//         if (A_E == 0.0) {
//             return A_O;
//         }
//         else if (A_O == 1.0 && A_E == 1.0) {
//             throw new InsufficientDataException(
//                     "Insufficient variation. Most likely, the raters only used a single category which yields an expected agreement of 1.0. In this case, it is not possible to make any statement about the other categories and thus the agreement of the study itself.");
//         }
//         else {
//             return (A_O - A_E) / (1.0 - A_E);
//         }
//     }
// 
//     protected abstract double calculateObservedAgreement();
// 
//     protected double calculateExpectedAgreement()
//     {
//         return 0.0;
//     }
// }
// 
// Path: dkpro-statistics-agreement/src/main/java/org/dkpro/statistics/agreement/InsufficientDataException.java
// public class InsufficientDataException
//     extends RuntimeException
// {
//     private static final long serialVersionUID = -3081535421752493402L;
// 
//     public InsufficientDataException()
//     {
//         super();
//     }
// 
//     public InsufficientDataException(final String message, final Throwable cause)
//     {
//         super(message, cause);
//     }
// 
//     public InsufficientDataException(final String message)
//     {
//         super(message);
//     }
// 
//     public InsufficientDataException(final Throwable cause)
//     {
//         super(cause);
//     }
// }


// Path: dkpro-statistics-agreement/src/main/java/org/dkpro/statistics/agreement/coding/CodingAgreementMeasure.java
import java.util.Map;
import org.dkpro.statistics.agreement.AgreementMeasure;
import org.dkpro.statistics.agreement.InsufficientDataException;

/*
 * Copyright 2014
 * 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 org.dkpro.statistics.agreement.coding;



/**
 * Abstract base class of agreement measures for {@link ICodingAnnotationStudy}s.
 * 
 * @author Christian M. Meyer
 */
public abstract class CodingAgreementMeasure
    extends AgreementMeasure
    implements ICodingAgreementMeasure
{
    protected ICodingAnnotationStudy study;

    /**
     * Initializes the instance for the given annotation study. The study should never be null.
     */
    public CodingAgreementMeasure(final ICodingAnnotationStudy study)
    {
        this.study = study;
    }

    @Override
    public double calculateObservedAgreement()
    {
        if (study.getCategoryCount() <= 1) {
            throw new InsufficientDataException(