package de.hsmannheim.iws2014.analyzers;

import org.apache.lucene.analysis.TokenFilter;
import org.apache.lucene.analysis.TokenStream;

import java.io.IOException;

/**
 * Actually transforms each token.
 */
public final class PigLatinFilter extends TokenFilter {

    public static final String VOCALS = "aeio";

    public PigLatinFilter(TokenStream stream) {
        super(stream);
    }

    @Override
    public boolean incrementToken() throws IOException {
        return true;
    }
}


@@ -133,35 +133,152 @@
 am;%0A
-%0Aimport java.io.IOException
+import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;%0A%0Aimport java.io.IOException;%0Aimport java.util.Arrays;%0Aimport java.util.List
 ;%0A%0A/
@@ -425,16 +425,59 @@
 aeio%22;%0A%0A
+    private final CharTermAttribute term;%0A%0A
     publ
@@ -539,16 +539,75 @@
 tream);%0A
+        this.term = addAttribute(CharTermAttribute.class);%0A
     %7D%0A%0A 
@@ -676,16 +676,376 @@
 ption %7B%0A
+        if (!input.incrementToken()) return false;%0A%0A        StringBuilder sTerm = new StringBuilder(term);%0A        char firstChar = sTerm.charAt(0);%0A%0A        if(!VOCALS.contains(%22%22+firstChar)) %7B%0A            sTerm.deleteCharAt(0);%0A            sTerm.append(firstChar);%0A        %7D%0A%0A        sTerm.append(%22ay%22);%0A        term.setEmpty();%0A        term.append(sTerm);%0A%0A
         

Implement pig latin conversion