Tim Fletcher wrote:
> http://tfletcher.com/lib/double_metaphone.rb
> 
> Adapted from the PHP version. There's at least one person looking for
> it:

Very cool! Maybe cook up a gem?

I've played with it for a few minutes, and look!

   require 'double_metaphone'

   module SpellChecker
     def self.words
       @words ||= {}
     end

     def self.add_word(word)
       word.downcase!
       raise ArgumentError unless word =~ /^[a-z]+$/
       words[word.to_sym] = DoubleMetaphone[word]
     end

     def self.valid? word
       words.has_key? word.to_sym
     end

     def self.check(word)
       word.downcase!

       if valid? word
         puts "`#{word}' is valid"
       else
         puts "`#{word}' is invalid. did you mean one of these?"
         key = DoubleMetaphone[word]
         words.select{|w, k| k == key}.each do |alt|
           puts " * #{alt.first}"
         end
       end
     end
   end

A bit rough, but hey.

Thanks mate!


Daniel