postmodern / ffi-hunspell

Ruby FFI bindings for Hunspell.
MIT License
48 stars 24 forks source link

Usage with a paragraph of text? #21

Closed oyeanuj closed 7 years ago

oyeanuj commented 7 years ago

Hi @postmodern, firstly, thank you for creating this library. I was curious if there was any example of using it with a paragraph of text? Or is it only meant to be used one word at a time and get suggestions for that word?

Is there a performant way to feed in a paragraph, and get a hash of the problem-word, its offset, and its suggestions?

Thank you!

postmodern commented 7 years ago

I believe you have to lex the paragraph yourself and run each word against the dictionary. Probably something like str.split(/\W+/).each_with_index { |word,index| ... }.