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

import org.dkpro.statistics.agreement.IAnnotationUnit;
import org.dkpro.statistics.agreement.coding.CodingAgreementMeasure;
import org.dkpro.statistics.agreement.coding.ICodingAnnotationItem;
import org.dkpro.statistics.agreement.coding.ICodingAnnotationStudy;
import org.dkpro.statistics.agreement.coding.ICodingItemSpecificAgreement;
import org.dkpro.statistics.agreement.distance.SetAnnotation;

/**
 * Implementation of a simple "max" percentage agreement measure for calculating
 * the inter-rater agreement for two or more raters applying set-valued
 * annotations. The measure is neither chance-corrected nor weighted.<br>
 * <br>
 * References:
 * <ul>
 * <li>Jean Véronis. A study of polysemy judgements and inter-annotator
 * agreement. In Proceedings of SENSEVAL-1, 1998.</li>
 * </ul>
 *
 * @author Tristan Miller
 */
public class MaxPercentageAgreement
    extends CodingAgreementMeasure
    implements ICodingItemSpecificAgreement /* , IRaterAgreement */
{

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

    /**
     * Calculates the inter-rater agreement for the given annotation item. This
     * is the basic step that is performed for each item of an annotation study,
     * when calling {@link #calculateAgreement()}.
     *
     * @throws NullPointerException
     *             if the given item is null.
     */
    @Override
    public double doCalculateItemAgreement(final ICodingAnnotationItem item)
    {
        SetAnnotation setAnnotation = null;
        for (IAnnotationUnit annotationUnit : item.getUnits()) {
            SetAnnotation raterSetAnnotation = (SetAnnotation) (annotationUnit
                    .getCategory());
            if (setAnnotation == null) {
                setAnnotation = new SetAnnotation(raterSetAnnotation);
            }
            else {
                setAnnotation.retainAll(raterSetAnnotation);
            }
            if (setAnnotation.size() == 0) {
                return 0.0;
            }
        }
        return setAnnotation.size() == 0 ? 0.0 : item.getRaterCount();
    }

    /**
     * Calculates the inter-rater agreement for the given annotation item. This
     * is the basic step that is performed for each item of an annotation study,
     * when calling {@link #calculateAgreement()}.
     *
     * @throws NullPointerException
     *             if the given item is null.
     */
    public double calculateItemAgreement(final ICodingAnnotationItem item)
    {
        return doCalculateItemAgreement(item) / item.getRaterCount();
    }

}

@@ -915,289 +915,8 @@
 it;%0A
-import org.dkpro.statistics.agreement.coding.CodingAgreementMeasure;%0Aimport org.dkpro.statistics.agreement.coding.ICodingAnnotationItem;%0Aimport org.dkpro.statistics.agreement.coding.ICodingAnnotationStudy;%0Aimport org.dkpro.statistics.agreement.coding.ICodingItemSpecificAgreement;%0A
 impo
@@ -973,16 +973,16 @@
 tation;%0A
+
 %0A/**%0A * 
@@ -1325,16 +1325,20 @@
 ent. In 
+%3Cem%3E
 Proceedi
@@ -1354,16 +1354,21 @@
 NSEVAL-1
+%3C/em%3E
 , 1998.%3C
@@ -1743,32 +1743,32 @@
 dy study)%0A    %7B%0A
-
         super(st
@@ -1773,16 +1773,74 @@
 study);%0A
+        ensureTwoRaters();%0A        warnIfMissingValues();%0A
     %7D%0A%0A 
@@ -3181,32 +3181,46 @@
 s null.%0A     */%0A
+    @Override%0A
     public doubl

Add rater/missing value checks to MaxPercentageAgreement