Search in sources :

Example 1 with Russian

use of org.languagetool.language.Russian in project languagetool by languagetool-org.

the class RussianSimpleReplaceRuleTest method testRule.

@Test
public void testRule() throws IOException {
    RussianSimpleReplaceRule rule = new RussianSimpleReplaceRule(TestTools.getMessages("ru"));
    RuleMatch[] matches;
    JLanguageTool langTool = new JLanguageTool(new Russian());
    // correct sentences:
    matches = rule.match(langTool.getAnalyzedSentence("Рост кораллов тут самый быстрый,"));
    assertEquals(0, matches.length);
    matches = rule.match(langTool.getAnalyzedSentence("Книга была порвана."));
    assertEquals(0, matches.length);
    // incorrect sentences:
    matches = rule.match(langTool.getAnalyzedSentence("Книга была порвата."));
    assertEquals(1, matches.length);
    assertEquals(1, matches[0].getSuggestedReplacements().size());
    assertEquals("порвана", matches[0].getSuggestedReplacements().get(0));
}
Also used : RuleMatch(org.languagetool.rules.RuleMatch) Russian(org.languagetool.language.Russian) JLanguageTool(org.languagetool.JLanguageTool) Test(org.junit.Test)

Example 2 with Russian

use of org.languagetool.language.Russian in project languagetool by languagetool-org.

the class RussianUnpairedBracketsRuleTest method testRuleRussian.

@Test
public void testRuleRussian() throws IOException {
    RussianUnpairedBracketsRule rule = new RussianUnpairedBracketsRule(TestTools.getEnglishMessages(), new Russian());
    RuleMatch[] matches;
    JLanguageTool langTool = new JLanguageTool(new Russian());
    // correct sentences:
    matches = rule.match(Collections.singletonList(langTool.getAnalyzedSentence("(О жене и детях не беспокойся, я беру их на свои руки).")));
    assertEquals(0, matches.length);
    // correct sentences:
    matches = rule.match(Collections.singletonList(langTool.getAnalyzedSentence("Позже выходит другая «южная поэма» «Бахчисарайский фонтан» (1824).")));
    assertEquals(0, matches.length);
    matches = rule.match(Collections.singletonList(langTool.getAnalyzedSentence("А \"б\" Д.")));
    assertEquals(0, matches.length);
    matches = rule.match(Collections.singletonList(langTool.getAnalyzedSentence("а), б), Д)..., ДД), аа) и 1а)")));
    assertEquals(0, matches.length);
    // incorrect sentences:
    matches = rule.match(Collections.singletonList(langTool.getAnalyzedSentence("В таком ключе был начат в мае 1823 в Кишинёве роман в стихах 'Евгений Онегин.")));
    assertEquals(1, matches.length);
}
Also used : Russian(org.languagetool.language.Russian) RuleMatch(org.languagetool.rules.RuleMatch) JLanguageTool(org.languagetool.JLanguageTool) Test(org.junit.Test)

Example 3 with Russian

use of org.languagetool.language.Russian in project languagetool by languagetool-org.

the class RussianCompoundRuleTest method setUp.

@Before
public void setUp() throws Exception {
    lt = new JLanguageTool(new Russian());
    rule = new RussianCompoundRule(TestTools.getEnglishMessages());
}
Also used : Russian(org.languagetool.language.Russian) JLanguageTool(org.languagetool.JLanguageTool) Before(org.junit.Before)

Aggregations

JLanguageTool (org.languagetool.JLanguageTool)3 Russian (org.languagetool.language.Russian)3 Test (org.junit.Test)2 RuleMatch (org.languagetool.rules.RuleMatch)2 Before (org.junit.Before)1