Search in sources :

Example 1 with Malayalam

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

the class MorfologikMalayalamSpellerRuleTest method testMorfologikSpeller.

@Test
public void testMorfologikSpeller() throws IOException {
    final Malayalam language = new Malayalam();
    final MorfologikMalayalamSpellerRule rule = new MorfologikMalayalamSpellerRule(TestTools.getMessages("ml"), language);
    RuleMatch[] matches;
    final JLanguageTool langTool = new JLanguageTool(language);
    // correct sentences:
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("എന്തുകൊണ്ട്‌ അംഗത്വം")).length);
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("എങ്ങനെ അംഗമാകാം?")).length);
    //test for "LanguageTool":
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("LanguageTool")).length);
    assertEquals(0, rule.match(langTool.getAnalyzedSentence(",")).length);
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("123454")).length);
    //incorrect sentences:
    matches = rule.match(langTool.getAnalyzedSentence("Zolw"));
    // check match positions:
    assertEquals(1, matches.length);
    assertEquals(0, matches[0].getFromPos());
    assertEquals(4, matches[0].getToPos());
    assertEquals(matches[0].getSuggestedReplacements().isEmpty(), true);
    matches = rule.match(langTool.getAnalyzedSentence("എaങ്ങനെ"));
    assertEquals(1, matches.length);
    assertEquals(0, matches[0].getFromPos());
    assertEquals(7, matches[0].getToPos());
    assertEquals(matches[0].getSuggestedReplacements().get(0), "എങ്ങനെ");
    assertEquals(1, rule.match(langTool.getAnalyzedSentence("aõh")).length);
    assertEquals(1, rule.match(langTool.getAnalyzedSentence("a")).length);
}
Also used : Malayalam(org.languagetool.language.Malayalam) RuleMatch(org.languagetool.rules.RuleMatch) JLanguageTool(org.languagetool.JLanguageTool) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 JLanguageTool (org.languagetool.JLanguageTool)1 Malayalam (org.languagetool.language.Malayalam)1 RuleMatch (org.languagetool.rules.RuleMatch)1