/* LanguageTool, a natural language style checker 
 * Copyright (C) 2012 Marcin Miłkowski (http://www.languagetool.org)
 * 
 * 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.rules.ru;

import java.io.IOException;
import java.util.ResourceBundle;

import org.languagetool.Language;
import org.languagetool.rules.Example;
import org.languagetool.rules.spelling.morfologik.MorfologikSpellerRule;

public final class MorfologikRussianSpellerRule extends MorfologikSpellerRule {

  public static final String RULE_ID = "MORFOLOGIK_RULE_RU_RU";

  private static final String RESOURCE_FILENAME = "/ru/hunspell/ru_RU.dict";

  public MorfologikRussianSpellerRule(ResourceBundle messages, Language language) throws IOException {
    super(messages, language);
    addExamplePair(Example.wrong("Все счастливые семьи похожи друг на друга, <marker>каждя</marker> несчастливая семья несчастлива по-своему."),
                   Example.fixed("Все счастливые семьи похожи друг на друга, <marker>каждая</marker> несчастливая семья несчастлива по-своему."));
  }

  @Override
  public String getFileName() {
    return RESOURCE_FILENAME;
  }

  @Override
  public String getId() {
    return RULE_ID;
  }

}

@@ -968,25 +968,199 @@
 til.
-ResourceBundle;%0D%0A
+ArrayList;%0D%0Aimport java.util.List;%0D%0Aimport java.util.ResourceBundle;%0D%0Aimport java.util.regex.Pattern;%0D%0A%0D%0Aimport org.languagetool.AnalyzedToken;%0D%0Aimport org.languagetool.AnalyzedTokenReadings;
 %0D%0Aim
@@ -1535,16 +1535,105 @@
 .dict%22;%0D
+%0A  %0D%0A  private static final Pattern RUSSIAN_LETTERS = Pattern.compile(%22.*%5B%D0%B0-%D1%8F%D1%91%D0%90-%D0%AF%D0%81%5D.*%22);%0D
 %0A%0D%0A  pub
@@ -2216,11 +2216,481 @@
 %0A  %7D%0D%0A%0D%0A
+  @Override%0D%0A  protected boolean ignoreToken(AnalyzedTokenReadings%5B%5D tokens, int idx) throws IOException %7B%0D%0A  List%3CString%3E words = new ArrayList%3C%3E();%0D%0A  for (AnalyzedTokenReadings token : tokens) %7B%0D%0A     words.add(token.getToken());%0D%0A  %7D%0D%0A   String word = tokens%5Bidx%5D.getToken();  %0D%0A   // don't check words that don't have  letters%0D%0A      if (!RUSSIAN_LETTERS.matcher(word).matches()) %7B%0D%0A          return true;%0D%0A      %7D%0D%0A%0D%0A    return ignoreWord(words, idx);%0D%0A  %7D%0D%0A%0D%0A  %0D%0A
 %7D%0D%0A

fix for latin letters. Thanks to arysin for idea.