From: Lloyd Linklater Date: 2008-09-03T23:09:05+09:00 Subject: Re: How to match words that rhyme? Here is a crude start based on an old version I wrote in Pascal. It should give you a place to start. (Please do not be TOO brutal in critique. I am new with writing Ruby algorithms. Elegance will come.) class Soundex def soundsAlike word1, word2 soundex(word1) == soundex(word2) end def soundex w w.upcase! temp1 = w[0,1] 1.upto(w.length - 1) { |i| case w[i, 1] when 'B','F','P','V' temp1 += '1' when 'C','G','J','K','Q','S','X','Z' temp1 += '2' when 'D','T' temp1 += '3' when 'L' temp1 += '4' when 'M', 'N' temp1 += '5' when 'R' temp1 += '6' end } i = 1 while i < temp1.length - 1 do if temp1[i] == temp1[i + 1] temp1[i] = '' else i += 1 end end temp1 end end s = Soundex.new p s.soundsAlike('their', 'there') # returns true -- Posted via http://www.ruby-forum.com/.