java 语言工具库,找不到依赖项
java language tool library, cannot find dependency
我正在使用 this example code to use the API. I don't want to use maven so I downloaded the jar files from here,并将 org 和 lib 中的 Jar 文件包含到构建路径中,然后尝试 运行 示例代码。我收到此错误:
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/",然后将 languages.jar 添加到您的类路径中其他 JAR。“
显然,语言实现本身被打包到单独的 jar 中。你需要的是语言-en.jar:
https://search.maven.org/remotecontent?filepath=org/languagetool/language-en/3.5/language-en-3.5.jar
你可以在这里看到:
jameson@spinach:~$ jar -tf language-en-3.5.jar | grep BritishEnglish
org/languagetool/language/BritishEnglish.class
尝试下载并将其添加到您的类路径中。还要确保执行文档中的项目: http://wiki.languagetool.org/java-api#toc4 。我不建议重新打包依赖 jar,那很笨拙。我也建议改用 maven。
我正在使用 this example code to use the API. I don't want to use maven so I downloaded the jar files from here,并将 org 和 lib 中的 Jar 文件包含到构建路径中,然后尝试 运行 示例代码。我收到此错误:
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/",然后将 languages.jar 添加到您的类路径中其他 JAR。“
显然,语言实现本身被打包到单独的 jar 中。你需要的是语言-en.jar:
https://search.maven.org/remotecontent?filepath=org/languagetool/language-en/3.5/language-en-3.5.jar
你可以在这里看到:
jameson@spinach:~$ jar -tf language-en-3.5.jar | grep BritishEnglish
org/languagetool/language/BritishEnglish.class
尝试下载并将其添加到您的类路径中。还要确保执行文档中的项目: http://wiki.languagetool.org/java-api#toc4 。我不建议重新打包依赖 jar,那很笨拙。我也建议改用 maven。