【问题标题】:Is there a way to stop Aspell from suggesting certain words (say, offensive) to incorrect spellings in R?有没有办法阻止 Aspell 向 R 中的不正确拼写建议某些单词(例如,冒犯性的)?
【发布时间】:2014-08-07 04:57:20
【问题描述】:

我正在使用 R 中 utils 包的 aspell 函数对我的文本进行拼写检查。此外,我正在尝试为 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]

【问题讨论】:

  • 别被冒犯了?但很明显:从外部编辑您的源字典以删除任何不需要的单词。或者更好的是,关闭“建议”。
  • 我需要建议。我需要一些关于拼写错误的建议,即使它是错误的,但它不应该是“冒犯性的”。我尝试使用谷歌搜索如何从 aspell 的源字典中删除某些单词,但没有运气。无论我发现什么都太复杂了。如果您知道从源字典中删除某些单词的方法,请分享。谢谢。

标签: r aspell


【解决方案1】:

怎么样:

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

【讨论】:

    猜你喜欢
    • 2011-02-03
    • 1970-01-01
    • 1970-01-01
    • 2013-05-25
    • 2019-04-11
    • 2021-11-30
    • 2022-08-18
    • 1970-01-01
    相关资源
    最近更新 更多