Search in sources :

Example 1 with AustralianEnglish

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

the class MorfologikAustralianSpellerRuleTest method testSuggestions.

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

Example 2 with AustralianEnglish

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

the class MorfologikAustralianSpellerRuleTest method testMorfologikSpeller.

@Test
public void testMorfologikSpeller() throws IOException {
    AustralianEnglish language = new AustralianEnglish();
    MorfologikAustralianSpellerRule rule = new MorfologikAustralianSpellerRule(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);
    // check encoding isn't broken
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("A café")).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);
    //Australian dict:
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("Agnathia")).length);
    //incorrect sentences:
    RuleMatch[] matches1 = rule.match(langTool.getAnalyzedSentence("behavior"));
    // check match positions:
    assertEquals(1, matches1.length);
    assertEquals(0, matches1[0].getFromPos());
    assertEquals(8, matches1[0].getToPos());
    assertEquals("behaviour", matches1[0].getSuggestedReplacements().get(0));
    assertEquals(1, rule.match(langTool.getAnalyzedSentence("aõh")).length);
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("a")).length);
    //based on replacement pairs:
    RuleMatch[] matches2 = rule.match(langTool.getAnalyzedSentence("He teached us."));
    // check match positions:
    assertEquals(1, matches2.length);
    assertEquals(3, matches2[0].getFromPos());
    assertEquals(10, matches2[0].getToPos());
    assertEquals("taught", matches2[0].getSuggestedReplacements().get(0));
}
Also used : RuleMatch(org.languagetool.rules.RuleMatch) JLanguageTool(org.languagetool.JLanguageTool) AustralianEnglish(org.languagetool.language.AustralianEnglish) Test(org.junit.Test)

Aggregations

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