// Path: dkpro-statistics-agreement/src/main/java/org/dkpro/statistics/agreement/IChanceCorrectedDisagreement.java
// public interface IChanceCorrectedDisagreement
//     extends IAgreementMeasure
// {
//     /**
//      * Returns the observed disagreement of an annotation study. The observed disagreement is
//      * basically the proportion of annotation units that the raters disagree on divided by the
//      * number of units in the given study.
//      */
//     public double calculateObservedDisagreement();
// 
//     /**
//      * Returns the expected disagreement of an annotation study. The expected disagreement is the
//      * proportion of disagreement that would be expected by chance alone. The expected disagreement
//      * should be equal to the observed disagreement if each rater makes a random decision for each
//      * unit.
//      */
//     public double calculateExpectedDisagreement();
// }
// 
// 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);
// 
// }


import java.math.BigDecimal;
import java.math.MathContext;
import java.util.Map;
import java.util.Map.Entry;
import org.dkpro.statistics.agreement.IChanceCorrectedDisagreement;
import org.dkpro.statistics.agreement.distance.IDistanceFunction;
/*
 * 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;



/**
 * Generalization of Cohen's (1960) kappa-measure for calculating a chance-corrected inter-rater
 * agreement for multiple raters with arbitrary distance/weighting functions. Before an inter-rater
 * agreement can be calculated, an {@link IDistanceFunction} instance needs to be assigned.<br>
 * <br>
 * References:
 * <ul>
 * <li>Cohen, J.: A Coefficient of Agreement for Nominal Scales. Educational and Psychological
 * Measurement 20(1):37-46, Beverly Hills, CA: Sage Publications, 1960.
 * <li>Cohen, J.: Weighted kappa: Nominal scale agreement with provision for scaled disagreement or
 * partial credit. Psychological Bulletin 70(4):213-220, Washington, DC: American Psychological
 * Association, 1968.
 * <li>Artstein, R. &amp; Poesio, M.: Inter-Coder Agreement for Computational Linguistics.
 * Computational Linguistics 34(4):555-596, Cambridge, MA: The MIT Press, 2008.
 * </ul>
 * 
 * @author Christian M. Meyer
 */
public class WeightedKappaAgreement
    extends WeightedAgreement
// Path: dkpro-statistics-agreement/src/main/java/org/dkpro/statistics/agreement/IChanceCorrectedDisagreement.java
// public interface IChanceCorrectedDisagreement
//     extends IAgreementMeasure
// {
//     /**
//      * Returns the observed disagreement of an annotation study. The observed disagreement is
//      * basically the proportion of annotation units that the raters disagree on divided by the
//      * number of units in the given study.
//      */
//     public double calculateObservedDisagreement();
// 
//     /**
//      * Returns the expected disagreement of an annotation study. The expected disagreement is the
//      * proportion of disagreement that would be expected by chance alone. The expected disagreement
//      * should be equal to the observed disagreement if each rater makes a random decision for each
//      * unit.
//      */
//     public double calculateExpectedDisagreement();
// }
// 
// 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/coding/WeightedKappaAgreement.java
import java.math.BigDecimal;
import java.math.MathContext;
import java.util.Map;
import java.util.Map.Entry;
import org.dkpro.statistics.agreement.IChanceCorrectedDisagreement;
import org.dkpro.statistics.agreement.distance.IDistanceFunction;

/*
 * 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;



/**
 * Generalization of Cohen's (1960) kappa-measure for calculating a chance-corrected inter-rater
 * agreement for multiple raters with arbitrary distance/weighting functions. Before an inter-rater
 * agreement can be calculated, an {@link IDistanceFunction} instance needs to be assigned.<br>
 * <br>
 * References:
 * <ul>
 * <li>Cohen, J.: A Coefficient of Agreement for Nominal Scales. Educational and Psychological
 * Measurement 20(1):37-46, Beverly Hills, CA: Sage Publications, 1960.
 * <li>Cohen, J.: Weighted kappa: Nominal scale agreement with provision for scaled disagreement or
 * partial credit. Psychological Bulletin 70(4):213-220, Washington, DC: American Psychological
 * Association, 1968.
 * <li>Artstein, R. &amp; Poesio, M.: Inter-Coder Agreement for Computational Linguistics.
 * Computational Linguistics 34(4):555-596, Cambridge, MA: The MIT Press, 2008.
 * </ul>
 * 
 * @author Christian M. Meyer
 */
public class WeightedKappaAgreement
    extends WeightedAgreement
    implements IChanceCorrectedDisagreement