Eclipse と共に LanguageTool を使用しています。API には、次のリンクを使用してアクセスできます: Click here . 特定の列にスペルミスのある単語があることを示すテキスト出力を取得できますが、入力として指定されたスペルミスの文字列の修正された文字列バージョンである出力を取得できません。これが私のコードです:
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
どうすればこれを実行できますか?