NOTE: This project has been abandoned. Use github.com/postmodern/ffi-hunspell instead.
However, the code is still available on the master branch.
A Ruby FFI interface to the Hunspell spelling checker.
“Hunspell is the spell checker of OpenOffice.org and Mozilla Firefox 3 & Thunderbird, Google Chrome, and it is also used by proprietary softwares, like Mac OS X, memoQ, Opera and SDL Trados.”
- http://hunspell.sourceforge.net/
It should work wherever Ruby FFI works (tested on Ruby 1.9.2, 1.8.7, JRuby 1.5.1).
This should be a drop-in replacement for rhunspell (github.com/tiendung/rhunspell), but using ffi.
On Mac OS X: Hunspell (libhunspell) is already installed on OSX 10.6.
On Debian:
apt-get install hunspell
gem install hunspell-ffi
require 'hunspell-ffi' # Detect language from ENV: dict = Hunspell.new("/path/to/dictionaries") # Directly specify language: dict = Hunspell.new("/path/to/dictionaries", "en_US") # directly specify dictionaries (legacy) dict = Hunspell.new("path/to/dictionaries/en_US.aff", "path/to/dictionaries/en_US.dic") dict.spell("walked") # => true same as #check, #check? dict.spell("woked") # => false dict.check?("woked") # => false dict.suggest("woked") # => ["woke", "worked", "waked", "woken", ...] dict.suggest("qwss43easd") # => [] dict.stem("Baumkuchen") # => ["Baumkuchen"] dict.analyze("Baumkuchen") # => [" st:Baumkuchen"] # Modify the run-time dictionary: dict.add("Geburtstagskuchen") dict.remove("Fichte")
Andreas Haller and contributors. Full list of contributors: github.com/ahx/hunspell-ffi/contributors
Hereby placed under public domain, do what you want, just do not hold me accountable.
Maybe we can think of a nice way to find to locate .dict files on a system or something. Anyways, feel free to fork and send pull requests. kthxbye. Andreas.
The source is on GitHub: github.com/ahx/hunspell-ffi
Test on Windows