Search code examples
rdictionaryhunspell

Problem with adding custom words to hunspell dictionary in R


I was able to figure out how to add custom words into the hunspell dictionary in R. However, I'm not sure why it's not being used in spell checking. Here is what I used:

library(hunspell)
#adding custom words into hunspell dictionary
hunspell::dictionary(lang = "en_US", affix = NULL, add_words = "bing", cache = TRUE)

but hunspell("bing") still determine "bing" is incorrect.

Anyone have experience with this before? Thanks.


Solution

  • The dictionary() function returns a new dictionary that you can use. It doesn't change the default behavior or anything. You can do

    library(hunspell)
    mydict <- dictionary(lang = "en_US", affix = NULL, add_words = "bing", cache = TRUE)
    hunspell("bing", dict=mydict)