ropensci/hunspell

hunspell_suggest is slow

dominiqueemmanuel opened this issue · 2 comments

Hi,

Thanks for this very useful package. However, I'am wondering why hunspell_suggest is so slow : is there a way to speed up this function (and maybe others functions in the package) ?

system.time(replicate(100,hunspell_suggest("wordd",dict="en_US")))
# utilisateur     système      écoulé 
#10.80        0.23       11.07 
## Very slow, isn't it ?!

Mmm not sure, maybe it's just expensive to calculate the distance between the word and every other word in the dictionary. It's a little faster if you vectorize:

system.time(hunspell_suggest(rep("wordd", 100), dict="en_US"))

It's gotten better now (version 2.9):

> system.time(replicate(100,hunspell_suggest("wordd",dict="en_US")))
   user  system elapsed 
  1.422   0.024   1.447 

I don't think it gets faster than this. Suggest is just an expensive operation because it has to calculate the distance between your string and every other word in the dictionary to find the closest neighbors.