Soundex.mesa
Copyright Ó 1985, 1992 by Xerox Corporation. All rights reserved.
Doug Terry, November 8, 1985 6:53:19 pm PST
Implements the Soundex algorithm presented in Knuth's "The Art of Computer Programming", Vol. 3, page 392. The Soundex encoding tends to group together variants of the same name; for instance, Johnson, Jansen, and Johansen have identical Soundex codes.
DIRECTORY
Rope USING [ROPE];
Soundex: CEDAR DEFINITIONS
~ BEGIN
SoundexCode: TYPE = Rope.ROPE;
The Soundex algorithm is as follows:
1. Retain the first letter of the name, and drop all occurrences of a, e, h, i, o, u, w, y in other positions.
2. Assign the following numbers to the remaining letters after the first:
b, f, p, v --> 1
c, g, j, k, q, s, x, z --> 2
d, t --> 3
l --> 4
m, n --> 5
r --> 6
3. If two or more letters with the same code were adjacent in the original name (before step 1), omit all but the first.
4. Convert to the form "letter, digit, digit, digit" by adding trailing zeros (if there are less than three digits), or by dropping rightmost digits (if there are more than three).
NameToCode: PROC [name: Rope.ROPE] RETURNS [SoundexCode];
Computes the Soundex code for the name.
END.
Doug Terry, November 8, 1985 6:50:44 pm PST
created.
Doug Terry, November 8, 1985 6:53:19 pm PST
changes to: Soundex, ~, END, DIRECTORY, Soundex