Search in sources :

Example 11 with Ukrainian

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

the class HiddenCharacterRuleTest method testRule.

@Test
public void testRule() throws IOException {
    final MixedAlphabetsRule rule = new MixedAlphabetsRule(TestTools.getMessages("uk"));
    final JLanguageTool langTool = new JLanguageTool(new Ukrainian());
    // correct sentences:
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("сміття")).length);
    //incorrect sentences:
    RuleMatch[] matches = rule.match(langTool.getAnalyzedSentence("смi­ття"));
    // check match positions:
    assertEquals(1, matches.length);
    assertEquals(Arrays.asList("сміття"), matches[0].getSuggestedReplacements());
}
Also used : Ukrainian(org.languagetool.language.Ukrainian) RuleMatch(org.languagetool.rules.RuleMatch) JLanguageTool(org.languagetool.JLanguageTool) Test(org.junit.Test)

Example 12 with Ukrainian

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

the class MorfologikUkrainianSpellerRuleTest method testProhibitedSuggestions.

@Test
public void testProhibitedSuggestions() throws IOException {
    MorfologikUkrainianSpellerRule rule = new MorfologikUkrainianSpellerRule(TestTools.getMessages("uk"), new Ukrainian());
    JLanguageTool langTool = new JLanguageTool(new Ukrainian());
    RuleMatch[] match = rule.match(langTool.getAnalyzedSentence("онлайннавчання"));
    assertEquals(1, match.length);
    //    assertEquals(Arrays.asList("онлайн-навчання"), match[0].getSuggestedReplacements());
    match = rule.match(langTool.getAnalyzedSentence("авіабегемот"));
    assertEquals(1, match.length);
    assertTrue("Should be empty: " + match[0].getSuggestedReplacements().toString(), match[0].getSuggestedReplacements().isEmpty());
    match = rule.match(langTool.getAnalyzedSentence("вело-маршрут"));
    assertEquals(1, match.length);
    assertEquals(Arrays.asList("веломаршрут"), match[0].getSuggestedReplacements());
    match = rule.match(langTool.getAnalyzedSentence("відео-маршрут"));
    assertEquals(1, match.length);
    assertEquals(new ArrayList<String>(), match[0].getSuggestedReplacements());
    match = rule.match(langTool.getAnalyzedSentence("вело-бегемот"));
    assertEquals(1, match.length);
    assertTrue("Unexpected suggestions: " + match[0].getSuggestedReplacements().toString(), match[0].getSuggestedReplacements().isEmpty());
}
Also used : Ukrainian(org.languagetool.language.Ukrainian) RuleMatch(org.languagetool.rules.RuleMatch) JLanguageTool(org.languagetool.JLanguageTool) Test(org.junit.Test)

Example 13 with Ukrainian

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

the class PunctuationCheckRuleTest method testRule.

@Test
public void testRule() throws IOException {
    PunctuationCheckRule rule = new PunctuationCheckRule(TestTools.getEnglishMessages());
    RuleMatch[] matches;
    JLanguageTool langTool = new JLanguageTool(new Ukrainian());
    // correct sentences:
    matches = rule.match(langTool.getAnalyzedSentence("Дві, коми. Ось: дві!!!"));
    assertEquals(0, matches.length);
    // correct sentences:
    matches = rule.match(langTool.getAnalyzedSentence("- Це ваша пряма мова?!!"));
    assertEquals(0, matches.length);
    // correct sentences:
    matches = rule.match(langTool.getAnalyzedSentence("Дві,- коми!.."));
    assertEquals(0, matches.length);
    // correct sentences:
    matches = rule.match(langTool.getAnalyzedSentence("Таке питання?.."));
    assertEquals(0, matches.length);
    // correct sentences:
    // поки що ігноруємо - не царська це справа :)
    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));
    // incorrect sentences:
    matches = rule.match(langTool.getAnalyzedSentence("Дві,, коми."));
    assertEquals(1, matches.length);
    // incorrect sentences:
    matches = rule.match(langTool.getAnalyzedSentence("Не там ,кома."));
    assertEquals(1, matches.length);
    // incorrect sentences:
    matches = rule.match(langTool.getAnalyzedSentence("Двокрапка:- з тире."));
    assertEquals(1, matches.length);
}
Also used : Ukrainian(org.languagetool.language.Ukrainian) RuleMatch(org.languagetool.rules.RuleMatch) JLanguageTool(org.languagetool.JLanguageTool) Test(org.junit.Test)

Example 14 with Ukrainian

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

the class TokenInflectionAgreementRuleTest method setUp.

//  static {
//    System.setProperty("org.languagetool.rules.uk.TokenInflectionAgreementRule.debug", "true");
//  }
@Before
public void setUp() throws IOException {
    rule = new TokenInflectionAgreementRule(TestTools.getMessages("uk"));
    langTool = new JLanguageTool(new Ukrainian());
//    TokenInflectionExceptionHelper.DEBUG = true;
}
Also used : Ukrainian(org.languagetool.language.Ukrainian) JLanguageTool(org.languagetool.JLanguageTool) Before(org.junit.Before)

Example 15 with Ukrainian

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

the class UppercaseSentenceStartRuleTest method testUkrainian.

@Test
public void testUkrainian() throws IOException {
    Ukrainian ukrainian = new Ukrainian();
    UppercaseSentenceStartRule rule = new UppercaseSentenceStartRule(TestTools.getEnglishMessages(), ukrainian);
    JLanguageTool lt = new JLanguageTool(ukrainian);
    assertEquals(0, rule.match(lt.analyzeText("Автор написав це речення з великої літери.")).length);
    RuleMatch[] matches = rule.match(lt.analyzeText("автор написав це речення з маленької літери."));
    assertEquals(1, matches.length);
    assertEquals(1, matches[0].getSuggestedReplacements().size());
    assertEquals("Автор", matches[0].getSuggestedReplacements().get(0));
    assertEquals(new ArrayList<RuleMatch>(), lt.check("Цей список з декількох рядків:\n\nрядок 1,\n\nрядок 2,\n\nрядок 3."));
    assertEquals(0, lt.check("Цей список з декількох рядків:\n\nрядок 1;\n\nрядок 2;\n\nрядок 3.").size());
    assertEquals(0, lt.check("Цей список з декількох рядків:\n\n 1) рядок 1;\n\n2) рядок 2;\n\n3)рядок 3.").size());
}
Also used : Ukrainian(org.languagetool.language.Ukrainian) RuleMatch(org.languagetool.rules.RuleMatch) JLanguageTool(org.languagetool.JLanguageTool) UppercaseSentenceStartRule(org.languagetool.rules.UppercaseSentenceStartRule) Test(org.junit.Test)

Aggregations

Ukrainian (org.languagetool.language.Ukrainian)15 JLanguageTool (org.languagetool.JLanguageTool)14 Test (org.junit.Test)10 RuleMatch (org.languagetool.rules.RuleMatch)8 Before (org.junit.Before)5 AnalyzedSentence (org.languagetool.AnalyzedSentence)2 AnalyzedTokenReadings (org.languagetool.AnalyzedTokenReadings)2 UppercaseSentenceStartRule (org.languagetool.rules.UppercaseSentenceStartRule)1 MultiWordChunker (org.languagetool.tagging.disambiguation.MultiWordChunker)1 DisambiguationRuleTest (org.languagetool.tagging.disambiguation.rules.DisambiguationRuleTest)1 UkrainianHybridDisambiguator (org.languagetool.tagging.disambiguation.uk.UkrainianHybridDisambiguator)1 DemoDisambiguator (org.languagetool.tagging.disambiguation.xx.DemoDisambiguator)1 UkrainianTagger (org.languagetool.tagging.uk.UkrainianTagger)1 SRXSentenceTokenizer (org.languagetool.tokenizers.SRXSentenceTokenizer)1 UkrainianWordTokenizer (org.languagetool.tokenizers.uk.UkrainianWordTokenizer)1