public
Description: Treat any ActiveRecord's string field as a dictionary to do word suggesting & spelling checking using Hunspell
Homepage: http://blog.spiragram.com/2008/9/5/acts_as_dictionary-rails-plugin
Clone URL: git://github.com/tiendung/acts_as_dictionary.git
name age message
file MIT-LICENSE Mon Aug 04 00:09:52 -0700 2008 Clean up ActsAsDictionary plugin after reliance... [jasoncheow]
file README Fri Sep 05 00:43:04 -0700 2008 update README for hunspell-1.2.7 [tiendung]
file Rakefile Sun Jul 06 04:43:29 -0700 2008 Reinstate buildings and streets tables and use ... [jasoncheow]
file init.rb Sun Aug 03 23:45:28 -0700 2008 remove require hunspell gem git-svn-id: svn://... [tiendung]
directory lib/ Fri Sep 05 00:29:47 -0700 2008 update git-svn-id: svn://203.125.43.235/blosso... [tiendung]
directory tasks/ Mon Aug 04 00:09:52 -0700 2008 Clean up ActsAsDictionary plugin after reliance... [jasoncheow]
directory test/ Sun Jul 06 04:43:29 -0700 2008 Reinstate buildings and streets tables and use ... [jasoncheow]
README
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 id: 1, name: "Name">
  
  >> Klass.suggest_*("Naem")
  => ["Name", "Name2"]
  
  >> Klass.check_*("Name")
  => true