我正在使用LanguageTool和Eclipse。 API可以通過鏈接訪問:Click here。我能夠從中得到文本輸出,其中顯示某些列拼寫錯誤的單詞,但我無法獲得作爲輸入提供拼寫錯誤字符串的正確字符串版本的輸出。這裏是我的代碼:如何在LanguageTool中輸出字符串中的建議句子?
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
我如何執行此操作?
非常感謝。 – Ravichandra