Saturday, August 2, 2008

Simplest Hunspell Ruby binding

Hunspell is one of the most powerful open source spelling checker. Recently I need to use spelling checking our startup project. Hunspell is the first choice.

There are several Hunspell bindings for Ruby:
They are gems with long and traditional bingding code.

Initially, I use Hunspell gem but after digging in to source code, I found a memory lick problem: the author forgot to free suggestion list after call Hunspell_suggest(pHunspell, &slst, str) function.

I decided to write my own binding with less code using RubyInline. Here is the result:
A simplest Hunspell Ruby Binding within 60 line of codes :)

Check it out at:

Update: Now the binding become a Rubygem, you can install it easily with following command:
"sudo gem install rhunspell"

No comments: