blob: fdecbab1028796276e4a3c8a434e4653293462e1 [file] [log] [blame]
Fred Drake3a0351c1998-04-04 07:23:21 +00001\section{Built-in Module \module{soundex}}
Guido van Rossume47da0a1997-07-17 16:34:52 +00002\label{module-soundex}
Fred Drakec520b691998-01-20 04:45:44 +00003\bimodindex{soundex}
Guido van Rossum3486f271996-12-12 17:02:21 +00004
Fred Drake23bc85a1998-03-08 07:56:48 +00005
Guido van Rossum3486f271996-12-12 17:02:21 +00006The soundex algorithm takes an English word, and returns an
7easily-computed hash of it; this hash is intended to be the same for
8words that sound alike. This module provides an interface to the
9soundex algorithm.
10
11Note that the soundex algorithm is quite simple-minded, and isn't
12perfect by any measure. Its main purpose is to help looking up names
Fred Drakec520b691998-01-20 04:45:44 +000013in databases, when the name may be misspelled --- soundex hashes common
Guido van Rossum3486f271996-12-12 17:02:21 +000014misspellings together.
15
16\begin{funcdesc}{get_soundex}{string}
17Return the soundex hash value for a word; it will always be a
186-character string. \var{string} must contain the word to be hashed,
Fred Drakec7086051998-04-07 19:58:19 +000019with no leading whitespace; the case of the word is ignored. (Note
20that the original algorithm produces a 4-character result.)
Guido van Rossum3486f271996-12-12 17:02:21 +000021\end{funcdesc}
22
23\begin{funcdesc}{sound_similar}{string1, string2}
24Compare the word in \var{string1} with the word in \var{string2}; this
25is equivalent to
Fred Drakefc931ec1998-02-13 21:49:12 +000026\code{get_soundex(\var{string1})} \code{==}
27\code{get_soundex(\var{string2})}.
Guido van Rossum3486f271996-12-12 17:02:21 +000028\end{funcdesc}
Fred Drakec7086051998-04-07 19:58:19 +000029
30
31\begin{seealso}
32
33\seetext{Donald E. Knuth, \emph{Sorting and Searching,} vol. 3 in
34``The Art of Computer Programming.'' Addison-Wesley Publishing
35Company: Reading, MA: 1973. pp.\ 391-392. Discusses the origin and
36usefulness of the algorithm, as well as the algorithm itself. Knuth
37gives his sources as \emph{U.S. Patents 1261167} (1918) and
38\emph{1435663} (1922), attributing the algorithm to Margaret K. Odell
39and Robert C. Russel. Additional references are provided.}
40
41\end{seealso}