An interface binding for the Aspell spelling checker.
Copyright 2007, 2008 Cloudburst, LLC. Licensed under the GPL 2.0. See included LICENSE file. Portions copyright 2005 Matthias Veit, Biro Eszter and used with permission.
The public certificate for the gem is here.
If you use this software, please make a donation, or recommend Evan at Working with Rails.
Raspell requires Aspell version 0.6 (http://www.aspell.net) and at least one Aspell dictionary.
sudo port install aspell aspell-dict-en
sudo apt-get install aspell libaspell-dev aspell-en
sudo gem install raspell -- --with-opt-dir=/opt/local
sudo gem install raspell
Aspell lets you check
words and suggest
corrections. For example:
require 'rubygems'
require 'raspell'
speller = Aspell.new("en_US")
speller.suggestion_mode = Aspell::NORMAL
string = "my haert wil go on"
string.gsub(/[\w\']+/) do |word|
if !speller.check(word)
# word is wrong
puts "Possible correction for #{word}:"
puts speller.suggest(word).first
end
end
This outputs:
Possible correction for haert:
heart
Possible correction for wil:
Will
Note that suggest
returns an array of suggestions even for words that are correctly spelled.
The most useful options are suggestion_mode
, and the passthrough option ignore_case
. Passthrough options have to be set as so:
speller.set_option("ignore-case", "true")
See http://aspell.net/man-html/The-Options.html for a list of the passthrough options.
The support forum is here.
Patches and contributions are very welcome. Please note that contributors are required to assign copyright for their additions to Cloudburst, LLC.