Hi,
I’m pretty much a beginner with Java and LanguageTool, and I keep running into an error message when trying to run the simple java application. I have the following code:
import org.languagetool.language.AmericanEnglish;
import org.languagetool.JLanguageTool;
import org.languagetool.rules.RuleMatch;
public class Grammar_Check_Java
{
public static void main (String args[])
{
JLanguageTool langTool = new JLanguageTool(new AmericanEnglish());
for (Rule rule : langTool.getAllActiveRules()) {
if (!rule.isSpellingRule()) {
langTool.disableRule(rule.getId());
}
}
List<RuleMatch> matches = langTool.check("A speling error");
for (RuleMatch match : matches) {
System.out.println("Potential typo at line " +
match.getLine() + ", column " +
match.getColumn() + ": " + match.getMessage());
System.out.println("Suggested correction(s): " +
match.getSuggestedReplacements());
}
}
}
And I keep getting the following errors:
Exception in thread “main” java.lang.Error: Unresolved compilation problems:
Rule cannot be resolved to a type
Type mismatch: cannot convert from element type org.languagetool.rules.Rule to Rule
List cannot be resolved to a type
at spell_checker.Grammar_Check_Java.main(Grammar_Check_Java.java:13)
Thanks for any help!