2

我正在使用Raspell中的包功能utils来拼写检查我的文本。此外,我正在尝试为 Aspell 检测到的不正确单词提取正确的单词。但是 Aspell 建议对一些不正确的词使用冒犯性的词。我不要那个。我如何阻止 Aspell 这样做?有没有办法只使用 R 从 Aspell 字典中删除某些单词?这就是我使用 Aspell 的方式。

spelling_mistakes <- aspell(file_location2,"Rd", control = c("--master=en_US"),
                            program = aspell_location)

incorrect_words_list <- spelling_mistakes[, 1]

correct_words_for_incorrect_words <- spelling_mistakes[, 5]
4

1 回答 1

2

怎么样:

badWords <- scan(url("http://www.bannedwordlist.com/lists/swearWords.txt"),
                 what=character(0))
## note that the 'bad' words include "job", and "hit" ... 
clean_words <- setdiff(spelling_mistakes[,5],badWords)

你没有给出一个可重现的例子,所以我没有测试过这个......

请注意,这不会提供替代建议。但它会让你走到那里。的文档aspell确实建议您可以使用替代字典,但您可以自己阅读... http://wordlist.aspell.net/other-dicts/

另请参阅http://lists.gnu.org/archive/html/aspell-user/2007-07/msg00004.html

于 2014-06-17T12:47:45.900 回答