class Phonetic::Caverphone

Caverphone created by the Caversham Project at the University of Otago. @see caversham.otago.ac.nz/files/working/ctp060902.pdf Caverphone: Phonetic Matching algorithm by David Hood (2002) This class implements this algorithm. @example

Phonetic::Caverphone.encode('Charmain') # => 'KMN111'
Phonetic::Caverphone.encode('Ellett')   # => 'ALT111'
Phonetic::Caverphone.encode('Siegmund') # => 'SKMNT1'

Constants

MAP

Public Class Methods

encode_word(word, options = {}) click to toggle source

Encode word to its Caverphone code

# File lib/phonetic/caverphone.rb, line 61
def self.encode_word(word, options = {})
  w = word.strip.downcase.gsub(/[^a-z]/, '')
  MAP.each { |r, v| w.gsub!(r, v) }
  w = w + '1' * 6
  w[0..5]
end