Search in sources :

Example 1 with CanadianEnglish

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

the class MorfologikCanadianSpellerRuleTest method testMorfologikSpeller.

@Test
public void testMorfologikSpeller() throws IOException {
    CanadianEnglish language = new CanadianEnglish();
    MorfologikBritishSpellerRule rule = new MorfologikBritishSpellerRule(TestTools.getMessages("en"), language);
    JLanguageTool langTool = new JLanguageTool(language);
    // correct sentences:
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("This is an example: we get behaviour as a dictionary word.")).length);
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("Why don't we speak today.")).length);
    //with doesn't
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("He doesn't know what to do.")).length);
    assertEquals(0, rule.match(langTool.getAnalyzedSentence(",")).length);
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("123454")).length);
    //incorrect sentences:
    RuleMatch[] matches = rule.match(langTool.getAnalyzedSentence("arbor"));
    // check match positions:
    assertEquals(1, matches.length);
    assertEquals(0, matches[0].getFromPos());
    assertEquals(5, matches[0].getToPos());
    assertEquals("arbour", matches[0].getSuggestedReplacements().get(0));
    assertEquals(1, rule.match(langTool.getAnalyzedSentence("aõh")).length);
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("a")).length);
}
Also used : RuleMatch(org.languagetool.rules.RuleMatch) CanadianEnglish(org.languagetool.language.CanadianEnglish) JLanguageTool(org.languagetool.JLanguageTool) Test(org.junit.Test)

Example 2 with CanadianEnglish

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

the class MorfologikCanadianSpellerRuleTest method testSuggestions.

@Test
public void testSuggestions() throws IOException {
    Language language = new CanadianEnglish();
    Rule rule = new MorfologikCanadianSpellerRule(TestTools.getMessages("en"), language);
    super.testNonVariantSpecificSuggestions(rule, language);
}
Also used : Language(org.languagetool.Language) CanadianEnglish(org.languagetool.language.CanadianEnglish) Rule(org.languagetool.rules.Rule) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 CanadianEnglish (org.languagetool.language.CanadianEnglish)2 JLanguageTool (org.languagetool.JLanguageTool)1 Language (org.languagetool.Language)1 Rule (org.languagetool.rules.Rule)1 RuleMatch (org.languagetool.rules.RuleMatch)1