// 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();
// }


import org.dkpro.statistics.agreement.IAnnotationStudy;
/*
 * 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.distance;


/**
 * Implementation of the {@link IDistanceFunction} interface for scoring the distance between
 * nominal-scaled categories. That is to say, categories are either equal (distance 0) or unequal
 * (distance 1). A typical example for nominal-scaled categories are the part of speech tags NOUN,
 * VERB, and ADJECTIVE. Mathematically, the nominal scale only allows for the equality operation,
 * but prohibits comparison, addition, and multiplication. The distance function makes no assumption
 * regarding the data type and thus allows for strings, enums, integers, etc.<br>
 * <br>
 * References:
 * <ul>
 * <li>Krippendorff, K.: Content Analysis: An Introduction to Its Methodology. Beverly Hills, CA:
 * Sage Publications, 1980.</li>
 * </ul>
 * 
 * @see IDistanceFunction
 * @author Kostadin Cholakov
 * @author Christian M. Meyer
 */
public class NominalDistanceFunction
    implements IDistanceFunction
{

    @Override
// 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/NominalDistanceFunction.java
import org.dkpro.statistics.agreement.IAnnotationStudy;

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


/**
 * Implementation of the {@link IDistanceFunction} interface for scoring the distance between
 * nominal-scaled categories. That is to say, categories are either equal (distance 0) or unequal
 * (distance 1). A typical example for nominal-scaled categories are the part of speech tags NOUN,
 * VERB, and ADJECTIVE. Mathematically, the nominal scale only allows for the equality operation,
 * but prohibits comparison, addition, and multiplication. The distance function makes no assumption
 * regarding the data type and thus allows for strings, enums, integers, etc.<br>
 * <br>
 * References:
 * <ul>
 * <li>Krippendorff, K.: Content Analysis: An Introduction to Its Methodology. Beverly Hills, CA:
 * Sage Publications, 1980.</li>
 * </ul>
 * 
 * @see IDistanceFunction
 * @author Kostadin Cholakov
 * @author Christian M. Meyer
 */
public class NominalDistanceFunction
    implements IDistanceFunction
{

    @Override
    public double measureDistance(final IAnnotationStudy study, final Object category1,