Search in sources :

Example 1 with Ukrainian

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

the class MultiWordChunkerTest method testDisambiguateMultiSpace.

@Test
public void testDisambiguateMultiSpace() throws Exception {
    Disambiguator chunker = new MultiWordChunker("/uk/multiwords.txt");
    JLanguageTool lt = new JLanguageTool(new Ukrainian());
    AnalyzedSentence analyzedSentence = lt.getAnalyzedSentence("для  годиться.");
    AnalyzedSentence disambiguated = chunker.disambiguate(analyzedSentence);
    AnalyzedTokenReadings[] tokens = disambiguated.getTokens();
    assertTrue(tokens[1].getReadings().toString().contains("<adv>"));
    assertTrue(tokens[4].getReadings().toString().contains("</adv>"));
}
Also used : Ukrainian(org.languagetool.language.Ukrainian) AnalyzedSentence(org.languagetool.AnalyzedSentence) JLanguageTool(org.languagetool.JLanguageTool) AnalyzedTokenReadings(org.languagetool.AnalyzedTokenReadings) Test(org.junit.Test)

Example 2 with Ukrainian

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

the class SimpleReplaceRuleTest method testRule.

@Test
public void testRule() throws IOException {
    SimpleReplaceRule rule = new SimpleReplaceRule(TestTools.getEnglishMessages());
    RuleMatch[] matches;
    JLanguageTool langTool = new JLanguageTool(new Ukrainian());
    // correct sentences:
    matches = rule.match(langTool.getAnalyzedSentence("Ці рядки повинні збігатися."));
    assertEquals(0, matches.length);
    // incorrect sentences:
    matches = rule.match(langTool.getAnalyzedSentence("Ці рядки повинні співпадати."));
    assertEquals(1, matches.length);
    assertEquals(2, matches[0].getSuggestedReplacements().size());
    assertEquals(Arrays.asList("збігатися", "сходитися"), matches[0].getSuggestedReplacements());
    matches = rule.match(langTool.getAnalyzedSentence("Нападаючий"));
    assertEquals(1, matches.length);
    assertEquals(Arrays.asList("Нападник", "Нападальний", "Нападний"), matches[0].getSuggestedReplacements());
    matches = rule.match(langTool.getAnalyzedSentence("Нападаючого"));
    assertEquals(1, matches.length);
    assertEquals(Arrays.asList("Нападник", "Нападальний", "Нападний"), matches[0].getSuggestedReplacements());
    // test ignoreTagged
    matches = rule.match(langTool.getAnalyzedSentence("щедрота"));
    assertEquals(1, matches.length);
    assertEquals(Arrays.asList("щедрість", "гойність", "щедриня"), matches[0].getSuggestedReplacements());
    matches = rule.match(langTool.getAnalyzedSentence("щедроти"));
    assertEquals(0, matches.length);
}
Also used : Ukrainian(org.languagetool.language.Ukrainian) RuleMatch(org.languagetool.rules.RuleMatch) JLanguageTool(org.languagetool.JLanguageTool) Test(org.junit.Test)

Example 3 with Ukrainian

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

the class SimpleReplaceSoftRuleTest method testRule.

@Test
public void testRule() throws IOException {
    SimpleReplaceSoftRule rule = new SimpleReplaceSoftRule(TestTools.getEnglishMessages());
    RuleMatch[] matches;
    JLanguageTool langTool = new JLanguageTool(new Ukrainian());
    // correct sentences:
    matches = rule.match(langTool.getAnalyzedSentence("Ці рядки повинні збігатися."));
    assertEquals(0, matches.length);
    matches = rule.match(langTool.getAnalyzedSentence("Цей брелок."));
    assertEquals(1, matches.length);
    assertEquals(Arrays.asList("дармовис"), matches[0].getSuggestedReplacements());
    matches = rule.match(langTool.getAnalyzedSentence("Не знайде спасіння."));
    assertEquals(1, matches.length);
    assertEquals(Arrays.asList("рятування", "рятунок", "порятунок", "визволення"), matches[0].getSuggestedReplacements());
    assertTrue(matches[0].getMessage().contains(": релігія"));
    //refl
    matches = rule.match(langTool.getAnalyzedSentence("відображаються"));
    assertEquals(1, matches.length);
    assertEquals(Arrays.asList("показуватися", "зображатися", "відбиватися"), matches[0].getSuggestedReplacements());
    assertTrue("No context: " + matches[0].getMessage(), matches[0].getMessage().contains(": математика"));
// test ignoreTagged
//    matches = rule.match(langTool.getAnalyzedSentence("щедрота"));
//    assertEquals(1, matches.length);
//    assertEquals(Arrays.asList("щедрість", "гойність", "щедриня"), matches[0].getSuggestedReplacements());
//
//    matches = rule.match(langTool.getAnalyzedSentence("щедроти"));
//    assertEquals(0, matches.length);
}
Also used : Ukrainian(org.languagetool.language.Ukrainian) RuleMatch(org.languagetool.rules.RuleMatch) JLanguageTool(org.languagetool.JLanguageTool) Test(org.junit.Test)

Example 4 with Ukrainian

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

the class TokenAgreementRuleTest method setUp.

@Before
public void setUp() throws IOException {
    rule = new TokenAgreementRule(TestTools.getMessages("uk"));
    langTool = new JLanguageTool(new Ukrainian());
}
Also used : Ukrainian(org.languagetool.language.Ukrainian) JLanguageTool(org.languagetool.JLanguageTool) Before(org.junit.Before)

Example 5 with Ukrainian

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

the class TokenVerbAgreementRuleTest method setUp.

@Before
public void setUp() throws IOException {
    rule = new TokenVerbAgreementRule(TestTools.getMessages("uk"));
    langTool = new JLanguageTool(new Ukrainian());
}
Also used : Ukrainian(org.languagetool.language.Ukrainian) JLanguageTool(org.languagetool.JLanguageTool) Before(org.junit.Before)

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