Search in sources :

Example 6 with BritishEnglish

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

the class JLanguageToolTest method spellCheckerDemoCodeForHomepageWithAddedWords.

@Ignore("not a test, but used on http://wiki.languagetool.org/java-spell-checker")
@Test
public void spellCheckerDemoCodeForHomepageWithAddedWords() throws IOException {
    JLanguageTool langTool = new JLanguageTool(new BritishEnglish());
    for (Rule rule : langTool.getAllRules()) {
        if (rule instanceof SpellingCheckRule) {
            ((SpellingCheckRule) rule).addIgnoreTokens(Arrays.asList("myspecialword", "anotherspecialword"));
        }
    }
    List<RuleMatch> matches = langTool.check("These are myspecialword and anotherspecialword");
    // => "0 matches"
    System.out.println(matches.size() + " matches");
}
Also used : BritishEnglish(org.languagetool.language.BritishEnglish) SpellingCheckRule(org.languagetool.rules.spelling.SpellingCheckRule) SpellingCheckRule(org.languagetool.rules.spelling.SpellingCheckRule) PatternRule(org.languagetool.rules.patterns.PatternRule) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

BritishEnglish (org.languagetool.language.BritishEnglish)6 Test (org.junit.Test)5 Ignore (org.junit.Ignore)3 JLanguageTool (org.languagetool.JLanguageTool)2 PatternRule (org.languagetool.rules.patterns.PatternRule)2 SpellingCheckRule (org.languagetool.rules.spelling.SpellingCheckRule)2 Before (org.junit.Before)1 Language (org.languagetool.Language)1 Rule (org.languagetool.rules.Rule)1 RuleMatch (org.languagetool.rules.RuleMatch)1