/* LanguageTool, a natural language style checker 
 * Copyright (C) 2006 Daniel Naber (http://www.danielnaber.de)
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
 * USA
 */
package org.languagetool.tagging.ru;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Locale;
import java.util.List;

import org.languagetool.AnalyzedToken;
import org.languagetool.AnalyzedTokenReadings;

import org.languagetool.chunking.ChunkTag;
import org.languagetool.tagging.BaseTagger;

/**  Part-of-speech tagger.
 * Russian dictionary originally developed by www.aot.ru and licensed under LGPL.
 * See readme.txt for details, the POS tagset is described in tagset.txt
 */
public class RussianTagger extends BaseTagger {

  @Override
  public String getManualAdditionsFileName() {
    return "/ru/added.txt";
  }

  @Override
  public String getManualRemovalsFileName() {
    return "/ru/removed.txt";
  }

  public RussianTagger() {
    super("/ru/russian.dict", new Locale("ru"));
  }

  @Override
    public List<AnalyzedTokenReadings> tag(List<String> sentenceTokens) throws IOException {
        List<AnalyzedTokenReadings> tokenReadings = new ArrayList<>();
        int pos = 0;
        for (String word : sentenceTokens) {
            boolean maymissingyo = false;
            if (word.length() > 1) {
                word = word.replace("о́", "о");
                word = word.replace("а́", "а");
                word = word.replace("е́", "е");
                word = word.replace("у́", "у");
                word = word.replace("и́", "и");
                word = word.replace("ы́", "ы");
                word = word.replace("э́", "э");
                word = word.replace("ю́", "ю");
                word = word.replace("я́", "я");
                word = word.replace("о̀", "о");
                word = word.replace("а̀", "а");
                word = word.replace("ѐ", "е");
                word = word.replace("у̀", "у");
                word = word.replace("ѝ", "и");
                word = word.replace("ы̀", "ы");
                word = word.replace("э̀", "э");
                word = word.replace("ю̀", "ю");
                word = word.replace("я̀", "я");
                word = word.replace("ʼ", "ъ");
            }
            if ((word.contains("е") || word.contains("Е")) && !(word.contains("ё"))  && !(word.contains("Ё"))) {
                maymissingyo = true;
            }

            List<AnalyzedToken> l = getAnalyzedTokens(word);

            AnalyzedTokenReadings atr = new AnalyzedTokenReadings(l, pos);

            if (maymissingyo) {
                List<ChunkTag> listChunkTags = new ArrayList<>();
                listChunkTags.add(new ChunkTag("MayMissingYO"));
                atr.setChunkTags(listChunkTags);
            }

            tokenReadings.add(atr);
            pos += word.length();

        }
        return tokenReadings;
    }

}

@@ -1991,24 +1991,428 @@
 th() %3E 1) %7B%0A
+%09      if  ( !(word.contains(%22%D1%91%22)) && !(word.contains(%22%D0%81%22)) && (word.contains(%22%D0%B5%22) %7C%7C word.contains(%22%D0%95%22)) && !(word.contains(%22%D0%B5%CC%81%22)) && !(word.contains(%22%D0%BE%CC%81%22)) &&%0A%09      !(word.contains(%22%D0%B0%CC%81%22)) && !(word.contains(%22%D1%83%CC%81%22)) && !(word.contains(%22%D0%B8%CC%81%22)) && !(word.contains(%22%D1%8E%CC%81%22)) && !(word.contains(%22%D1%8B%CC%81%22)) && !(word.contains(%22%D1%8D%CC%81%22)) && !(word.contains(%22%D1%8F%CC%81%22))  ) %7B%0A                maymissingyo = true;%0A            %7D;%0A
             
@@ -3337,161 +3337,8 @@
     
-  if ((word.contains(%22%D0%B5%22) %7C%7C word.contains(%22%D0%95%22)) && !(word.contains(%22%D1%91%22))  && !(word.contains(%22%D0%81%22))) %7B%0A                maymissingyo = true;%0A            %7D
 %0A%0A  

update "Missing "Ё" algoritm