Skip to content

Commit

Permalink
example code for spell checking
Browse files Browse the repository at this point in the history
  • Loading branch information
danielnaber committed Sep 21, 2016
1 parent c6cff34 commit 5408062
Showing 1 changed file with 14 additions and 0 deletions.
Expand Up @@ -27,6 +27,7 @@
import org.languagetool.rules.*;
import org.languagetool.rules.patterns.PatternRule;
import org.languagetool.rules.patterns.PatternToken;
import org.languagetool.rules.spelling.SpellingCheckRule;

import java.io.IOException;
import java.util.ArrayList;
Expand Down Expand Up @@ -72,6 +73,19 @@ public void spellCheckerDemoCodeForHomepage() throws IOException {
}
}

@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");
System.out.println(matches.size() + " matches"); // => "0 matches"
}

@Test
public void testEnglish() throws IOException {
//more error-free sentences to deal with possible regressions
Expand Down

0 comments on commit 5408062

Please sign in to comment.