As far as I know, Hunspell is the best open source spelling checking library. It is used by Firefox 3, Google Chrome, and Open Office. I also found Hunspell is easier to use than Aspell.
Get the plug-in at http://github.com/tiendung/acts_as_dictionary/tree/master
ActsAsDictionary
================
ActsAsDictionary creates Hunspell (http://hunspell.sourceforge.net/) dictionaries using data from ActiveRecord models and provides class methods to access these dictionaries.
Pre-requisites
==============
This plugin requires the Hunspell library and RubyInline gem.
To install Hunspell:
curl -O http://nchc.dl.sourceforge.net/sourceforge/hunspell/hunspell-1.2.7.tar.gz
tar -zxvf hunspell-1.2.7.tar.gz
cd hunspell-1.2.7
./configure
make
sudo make install
To install RubyInline:
gem install RubyInline
Setup
=====
Within a model, define the column you want to work with:
class Klass < ActiveRecord::Base
acts_as_dictionary :checks => :name
end
Or, if you want to create dictionaries using two or more columns
class Klass < ActiveRecord::Base
acts_as_dictionary :checks => [:name, :type]
end
Once done, you can proceed to generate basic Hunspell dictionary files with:
rake dict:generate
In the above example, the following files will be generated:
#{Rails.root}/dict/klass_names.aff
#{Rails.root}/dict/klass_names.dic
#{Rails.root}/dict/klass_types.aff
#{Rails.root}/dict/klass_types.dic
Each pair of these files (*.aff and *.dic) are Hunspell dictionary definition files which you can further configure if needed (see http://sourceforge.net/docman/display_doc.php?docid=29374&group_id=143754).
Note that if manually configure the files, running the dict:generate Rake task again will override your manual configurations.
Usage
=====
With this plugin, the following dynamic class methods are available (replace * with a column name you have specified to check):
>> Klass.find_by_*_with_spell_check("Naem")
=> #
>> Klass.suggest_*("Naem")
=> ["Name", "Name2"]
>> Klass.check_*("Name")
=> true
Tien Dung
http://free-and-happy.blogspot.com/






