我正在使用this示例代码来使用API。我不想使用maven,因此我从here下载了jar文件,并将org和lib中的jar文件包含到构建路径中,然后尝试运行示例代码。我得到这个错误:java语言工具库,无法找到依赖关系
Error:(15, 56) java: cannot find symbol
symbol: class BritishEnglish
location: class draft
Error:(3, 34) java: cannot find symbol
symbol: class BritishEnglish
location: package org.languagetool.language
这里是我的代码
import org.languagetool.JLanguageTool;
import org.languagetool.language.BritishEnglish;
import org.languagetool.rules.RuleMatch;
import java.io.*;
import java.util.List;
public class draft {
public static void main(String[] args) throws IOException {
JLanguageTool langTool = new JLanguageTool(new BritishEnglish());
// comment in to use statistical ngram data:
//langTool.activateLanguageModelRules(new File("/data/google-ngram-data"));
List<RuleMatch> matches = langTool.check("A sentence with a error in the Hitchhiker's Guide tot he Galaxy");
for (RuleMatch match : matches) {
System.out.println("Potential error at characters " +
match.getFromPos() + "-" + match.getToPos() + ": " +
match.getMessage());
System.out.println("Suggested correction(s): " +
match.getSuggestedReplacements());
}
}
}
我发现这个答案在网上,但我不明白。
“BritishEnglish位于”org“目录中,不在JAR中,但可以像这样放入JAR:”zip -r languages.jar org /“,然后将language.jar添加到类路径中,如其他JAR“。
这不是一个代码问题,因为它是一个构建/执行的问题。我们需要看到您的CLASSPATH以及您如何调用您的草稿课程。 – Jameson
@jameson我做了一个编辑,请检查它,也许你可以帮助 –