class Phonetic::Caverphone2
Caverphone
2.0 created by the Caversham Project at the University of Otago. @see caversham.otago.ac.nz/files/working/ctp150804.pdf Caverphone
Revisited by David Hood (2004) This class implements this algorithm. @example
Phonetic::Caverphone2.encode('Stevenson') # => 'STFNSN1111' Phonetic::Caverphone2.encode('Peter') # => 'PTA1111111'
Constants
- MAP
Public Class Methods
encode_word(word, options = {})
click to toggle source
Encode word to its Caverphone
2 code
# File lib/phonetic/caverphone2.rb, line 62 def self.encode_word(word, options = {}) w = word.strip.downcase.gsub(/[^a-z]/, '') MAP.each { |r, v| w.gsub!(r, v) } w = w + '1' * 10 w[0..9] end