javamacosnetbeanslanguagetool

Package org.languagetool.language.BritishEnglish does not exist


I am LanguageTools to implement a spell corrector. I am currently trying to run the example code which checks for basic spelling error in a string. I downloaded and imported languagetool-core-2.2.jar into my project library in Netbeans.

My imports are:

import org.languagetool.JLanguageTool;
import org.languagetool.language.BritishEnglish;
import org.languagetool.rules.RuleMatch;

My code is this:

JLanguageTool langTool = new JLanguageTool(new BritishEnglish());
for (Rule rule : langTool.getAllRules()) {
    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());
}

I am not getting any import errors for my first and third import but I am getting the error "Cannot find symbol: BritishEnglish" for my second import.

After getting frustrated for several hours trying to find a perfectly working .jar containing all the required packages, I have given up.

Could you please point me to a working .jar which will resolve the import errors?


Solution

  • There is no single JAR that contains everything you need. We (the LanguageTool) developers recommend using Maven or Gradle to manage the dependencies, as documented at http://wiki.languagetool.org/java-api.

    Also, LanguageTool 2.2 is really old, we're currently at 4.1.