April 2019
Beginner to intermediate
386 pages
11h 20m
English
An instance of the JLanguageTool class is created based on the language being checked. For this example, we choose American English. The available languages are found in the org.languagetool.language package:
JLanguageTool jLanguageTool = new JLanguageTool(new AmericanEnglish());
We used the first for loop to disable all checking except for spelling. The getAllRules method returns the rules currently used by the JLanguageTool instance. In the if statement, we check each rule and if it is not a spelling rule, we use the disableRule method to disable it:
for (Rule rule : jLanguageTool.getAllRules()) { if (!rule.isDictionaryBasedSpellingRule()) { jLanguageTool.disableRule(rule.getId()); }}
We choose a simple sentence with three ...
Read now
Unlock full access