package eu.modernmt.processing.transliteration;

import eu.modernmt.lang.Language;
import eu.modernmt.lang.UnsupportedLanguageException;
import eu.modernmt.processing.TextProcessor;
import eu.modernmt.processing.string.SentenceBuilder;
import org.apache.commons.lang.StringUtils;

import java.util.Map;
import java.util.regex.Matcher;

public class AlphabetNormalizer extends TextProcessor<SentenceBuilder, SentenceBuilder> {

    public AlphabetNormalizer(Language sourceLanguage, Language targetLanguage) throws UnsupportedLanguageException {
        super(sourceLanguage, targetLanguage);

        if (!Language.SERBIAN.isEqualOrMoreGenericThan(sourceLanguage))
            throw new UnsupportedLanguageException(sourceLanguage);
    }

    @Override
    public SentenceBuilder call(SentenceBuilder builder, Map<String, Object> metadata) {
        String text = builder.toString();
        String edited = Serbian.toLatin(text);

        if (!text.equals(edited)) {
            SentenceBuilder.Editor editor = builder.edit();
            editor.replace(0, text.length(), edited);
            editor.commit();
        }

        return builder;
    }

}

@@ -179,159 +179,29 @@
 or;%0A
-import eu.modernmt.processing.string.SentenceBuilder;%0Aimport org.apache.commons.lang.StringUtils;%0A%0Aimport java.util.Map;%0Aimport java.util.regex.Matcher
+%0Aimport java.util.Map
 ;%0A%0Ap
@@ -258,39 +258,21 @@
 or%3CS
-entenceBuilder, SentenceBuilder
+tring, String
 %3E %7B%0A
@@ -615,387 +615,100 @@
 ic S
-entenceBuilder call(SentenceBuilder builder, Map%3CString, Object%3E metadata) %7B%0A        String text = builder.toString();%0A        String edited = Serbian.toLatin(text);%0A%0A        if (!text.equals(edited)) %7B%0A            SentenceBuilder.Editor editor = builder.edit();%0A            editor.replace(0, text.length(), edited);%0A            editor.commit();%0A        %7D%0A%0A        return builder
+tring call(String text, Map%3CString, Object%3E metadata) %7B%0A        return Serbian.toLatin(text)
 ;%0A  

Fix AlphabetNormalizer invalid edit