我将 LanguageTool 与 Eclipse 一起使用。可以使用以下链接访问 API:单击此处。我能够从中获取文本输出,显示某些列的单词拼写错误,但我无法获得作为输入给出的拼写错误字符串的更正字符串版本的输出。这是我的代码:
JLanguageTool langTool = new JLanguageTool(new BritishEnglish());
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 line " +
match.getLine() + ", column " +
match.getColumn() + ": " + match.getMessage());
System.out.println("Suggested correction: " +
match.getSuggestedReplacements());
}
得到的输出是:
Potential error at line 0, column 17: Use <suggestion>an</suggestion> instead of 'a' if the following word starts with a vowel sound, e.g. 'an article', 'an hour'
Suggested correction: [an]
Potential error at line 0, column 32: Possible spelling mistake found
Suggested correction: [Hitch-hiker]
Potential error at line 0, column 51: Did you mean <suggestion>to the</suggestion>?
Suggested correction: [to the]
我希望输出是输入字符串的更正版本:
A sentence with an error in the Hitchhiker's Guide to the Galaxy
我该怎么做?