Codex

Soundex

Section: User Contributed Perl Documentation (3pm)

Updated: 2013-01-18

Index?action=index Return to Main Contents


NAME

Text::Soundex - Implementation of the soundex algorithm.

SYNOPSIS

DESCRIPTION

Soundex is a phonetic algorithm for indexing names by sound, as pronounced in English. The goal is for names with the same pronunciation to be encoded to the same representation so that they can be matched despite minor differences in spelling. Soundex is the most widely known of all phonetic algorithms and is often used (incorrectly) as a synonym for ``phonetic algorithm''. Improvements to Soundex are the basis for many modern phonetic algorithms. (Wikipedia, 2007)

This module implements the original soundex algorithm developed by Robert Russell and Margaret Odell, patented in 1918 and 1922, as well as a variation called ``American Soundex'' used for US census data, and current maintained by the National Archives and Records Administration (NARA).

The soundex algorithm may be recognized from Donald Knuth's The Art of Computer Programming. The algorithm described by Knuth is the NARA algorithm.

The value returned for strings which have no soundex encoding is defined using . The default value is , however values such as are commonly used alternatives.
For backward compatibility with older versions of this module the is exported into the caller's namespace as .
In scalar context, returns the soundex code of its first argument. In list context, a list is returned in which each element is the soundex code for the corresponding argument passed to . For example, the following code assigns the value :
To use to generate codes that can be used to search one of the publically available US Censuses, a variant of the soundex algorithm must be used:

An example of where these algorithm differ follows:

EXAMPLES

Donald Knuth's examples of names and the soundex codes they map to are listed below:

so:

LIMITATIONS

As the soundex algorithm was originally used a long time ago in the US it considers only the English alphabet and pronunciation. In particular, non-ASCII characters will be ignored. The recommended method of dealing with characters that have accents, or other unicode characters, is to use the Text::Unidecode module available from CPAN. Either use the module explicitly:

Or use the convenient wrapper routine:

Since the soundex algorithm maps a large space (strings of arbitrary length) onto a small space (single letter plus 3 digits) no inference can be made about the similarity of two strings which end up with the same soundex code. For example, both and end up with a soundex code of .

MAINTAINER

This module is currently maintain by Mark Mielke ( ).

HISTORY

Version 3 is a significant update to provide support for versions of Perl later than Perl 5.004. Specifically, the XS version of the soundex() subroutine understands strings that are encoded using UTF-8 (unicode strings).

Version 2 of this module was a re-write by Mark Mielke ( ) to improve the speed of the subroutines. The XS version of the soundex() subroutine was introduced in 2.00.
Version 1 of this module was written by Mike Stok ( ) and was included into the Perl core library set.
Dave Carlsen ( ) made the request for the NARA algorithm to be included. The NARA soundex page can be viewed at:
Ian Phillips ( ) and Rich Pinder ( ) supplied ideas and spotted mistakes for v1.x.

Index

NAME

SYNOPSIS

DESCRIPTION

EXAMPLES

LIMITATIONS

MAINTAINER

HISTORY