The Secret of Soundex, Page 3
This section is for all those folks interested in exactly how the four-letter Soundex code is generated.
But I admit, most of you probably won't be bothered about the theory.
So if you're just looking for the hands-on stuff, or have patience shorter than a toad's wedding tackle scroll on down and zip off to the next page. You don't really need to know all this stuff to get our sample VB project working anyhow.
But for the more boringly serious among us, here's how that four-letter code is generated:
The Soundex Rules
- Take the first letter of the word and make it the first letter of the Soundex code
- For each remaining letter in the word, grab its number from the below table and add it to the Soundex code
- If two or more letters with the same number appear next to one another, only one of them should be added to the code
- If the final Soundex code is greater than four characters, trim it down. If it's longer, append zeros until is has a length of four
The Soundex Table
|B, P, F, V||1|
|C, S, G, J, K, Q, X, Z||2|
The letters A,E,I,O,U,Y,H and W, as well as other characters are not counted.
All of these rules have been put together into two main Visual Basic functions. And we're going to take a peek at them, next...