/*
 * Copyright (C) 2012 Fabian Hirschmann <fabian@hirschm.net>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
package com.github.fhirschmann.clozegen.lib.annotators.en;

import com.github.fhirschmann.clozegen.lib.annotators.AbstractGapGenerator;
import com.github.fhirschmann.clozegen.lib.annotators.Gap;
import com.github.fhirschmann.clozegen.lib.annotators.GapGeneratorMetadata;
import de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.ART;
import java.util.Arrays;
import org.apache.uima.jcas.tcas.Annotation;

/**
 * Implements an Annotator for generating gaps for the English ARTICLES.
 *
 * This simply deletes the article and gives three choices: a, an, the.
 *
 * @author Fabian Hirschmann <fabian@hirschm.net>
 */
@GapGeneratorMetadata(languageCode = "en", wantedPosSubtag = ART.class)
public class ArticleGapGenerator extends AbstractGapGenerator {
    /** The language for this annotator. */
    protected static final String LANGUAGE = "en";

    /** The three English articles. */
    public static final String[] ARTICLES = new String[] {"a", "an", "the"};

    @Override
    public Gap generate(final Annotation subject) {
        if (Arrays.asList(ARTICLES).contains(subject.getCoveredText())) {
            final Gap gap = new Gap();

            gap.getValidAnswers().add(subject.getCoveredText());
            gap.getInvalidAnswers().add("a");
            gap.getInvalidAnswers().add("an");
            gap.getInvalidAnswers().add("the");

            return gap;
        }
        return null;
    }
}

@@ -1050,16 +1050,55 @@
 tadata;%0A
+import com.google.common.collect.Sets;%0A
 import d
@@ -1170,22 +1170,19 @@
 va.util.
-Arrays
+Set
 ;%0Aimport
@@ -1242,21 +1242,21 @@
 ents an 
-Annot
+gener
 ator for
@@ -1288,24 +1288,24 @@
 English 
-ARTICLES
+articles
 .%0A *%0A * 
@@ -1725,24 +1725,27 @@
 c final 
+Set%3C
 String
-%5B%5D
+%3E
  ARTICLE
@@ -1752,22 +1752,24 @@
 S = 
-new String%5B%5D %7B
+Sets.newHashSet(
 %22a%22,
@@ -1780,17 +1780,17 @@
 %22, %22the%22
-%7D
+)
 ;%0A%0A    @
@@ -1854,86 +1854,8 @@
 ) %7B%0A
-        if (Arrays.asList(ARTICLES).contains(subject.getCoveredText())) %7B%0A    
     
@@ -1882,28 +1882,24 @@
 new Gap();%0A%0A
-    
         gap.
@@ -1947,36 +1947,32 @@
 ext());%0A        
-    
 gap.getInvalidAn
@@ -1986,107 +1986,96 @@
 .add
-(%22a%22);%0A            gap.getInvalidAnswers().add(%22an%22);%0A            gap.getInvalidAnswers().add(%22the%22
+All(Sets.difference(ARTICLES,%0A                Sets.newHashSet(subject.getCoveredText()))
 );%0A%0A
@@ -2078,28 +2078,24 @@
 );%0A%0A        
- 
-   
 return gap;%0A
@@ -2098,39 +2098,8 @@
 ap;%0A
-        %7D%0A        return null;%0A
     

correct implementation of ArticleGapGenerator