gpt4 book ai didi

java语言工具库,找不到依赖

转载 作者:行者123 更新时间:2023-12-01 09:26:12 25 4
gpt4 key购买 nike

我正在使用this使用 API 的示例代码。我不想使用maven,所以我从here下载了jar文件,并将 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 中。您需要的位于 language-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。

关于java语言工具库,找不到依赖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39812863/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com