Module: Text::Metaphone::Rules

Defined in:
lib/text/metaphone.rb

Overview

:nodoc:all

Constant Summary collapse

STANDARD =

Metaphone rules. These are simply applied in order.

[ 
  # Regexp, replacement
  [ /([bcdfhjklmnpqrstvwxyz])\1+/,
                     '\1' ],  # Remove doubled consonants except g.
                              # [PHP] remove c from regexp.
  [ /^ae/,            'E' ],
  [ /^[gkp]n/,        'N' ],
  [ /^wr/,            'R' ],
  [ /^x/,             'S' ],
  [ /^wh/,            'W' ],
  [ /mb$/,            'M' ],  # [PHP] remove $ from regexp.
  [ /(?!^)sch/,      'SK' ],
  [ /th/,             '0' ],
  [ /t?ch|sh/,        'X' ],
  [ /c(?=ia)/,        'X' ],
  [ /[st](?=i[ao])/,  'X' ],
  [ /s?c(?=[iey])/,   'S' ],
  [ /[cq]/,           'K' ],
  [ /dg(?=[iey])/,    'J' ],
  [ /d/,              'T' ],
  [ /g(?=h[^aeiou])/, ''  ],
  [ /gn(ed)?/,        'N' ],
  [ /([^g]|^)g(?=[iey])/,
                    '\1J' ],
  [ /g+/,             'K' ],
  [ /ph/,             'F' ],
  [ /([aeiou])h(?=\b|[^aeiou])/,
                     '\1' ],
  [ /[wy](?![aeiou])/, '' ],
  [ /z/,              'S' ],
  [ /v/,              'F' ],
  [ /(?!^)[aeiou]+/,  ''  ],
]
BUGGY =

The rules for the ‘buggy’ alternate implementation used by PHP etc.

STANDARD.dup