Search in sources :

Example 1 with NewZealandEnglish

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

the class MorfologikNewZealandSpellerRuleTest method testMorfologikSpeller.

@Test
public void testMorfologikSpeller() throws IOException {
    NewZealandEnglish language = new NewZealandEnglish();
    MorfologikNewZealandSpellerRule rule = new MorfologikNewZealandSpellerRule(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);
    //special New Zealand content:
    assertEquals(0, rule.match(langTool.getAnalyzedSentence("Abercrombie")).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) NewZealandEnglish(org.languagetool.language.NewZealandEnglish) Test(org.junit.Test)

Example 2 with NewZealandEnglish

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

the class NewZealandReplaceRuleTest method setUp.

@Before
public void setUp() throws Exception {
    rule = new NewZealandReplaceRule(TestTools.getMessages("en"));
    langTool = new JLanguageTool(new NewZealandEnglish());
}
Also used : JLanguageTool(org.languagetool.JLanguageTool) NewZealandEnglish(org.languagetool.language.NewZealandEnglish) Before(org.junit.Before)

Example 3 with NewZealandEnglish

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

the class MorfologikNewZealandSpellerRuleTest method testSuggestions.

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

Aggregations

NewZealandEnglish (org.languagetool.language.NewZealandEnglish)3 Test (org.junit.Test)2 JLanguageTool (org.languagetool.JLanguageTool)2 Before (org.junit.Before)1 Language (org.languagetool.Language)1 Rule (org.languagetool.rules.Rule)1 RuleMatch (org.languagetool.rules.RuleMatch)1