我在我的 Java Maven 项目中包含了 LanguageTool 编码,如下所示;
Java 代码
List<Language> realLanguages = Languages.get();
for (Language language : realLanguages) {
System.out.println(language.getName() + " ==> " + language.getShortName());
if (language.getName().startsWith("English (US)")) {
JLanguageTool langTool = new JLanguageTool(language);
PatternRuleLoader patternRuleLoader = new PatternRuleLoader();
List<PatternRule> abstractPatternRuleList = new ArrayList<PatternRule>();
abstractPatternRuleList = patternRuleLoader.getRules(new File(LTPath + "/CustomGrammar.xml"));
System.out.println("\n\nDefault Active Rules: " + langTool.getAllActiveRules().size());
<-- More coding goes here -->
并且当从一个项目(在服务器'A'上)调用模块的 jar 时它工作得非常好,但是当从另一个项目(在服务器'B'上)调用时,同样会抛出下面附加的异常,“无法初始化英语分块器”。
依赖
<dependency>
<groupId>org.languagetool</groupId>
<artifactId>language-en</artifactId>
<version>3.1</version>
</dependency>
例外
请帮忙 !