Make a phonetic match string
──────────────────────────────────────────────────────────────────────────────
Syntax
GT_Fonetix(<cStr>) --> cFonStr
Arguments:
<cStr> - The input string
Returns:
cFonStr - A phonetic representation of the input string
Description:
Make a phonetic match string for a passed string.
Only works in english. Words with foreign roots
may not match very well. Words with more than one
syllable also translate poorly in some cases.
However this approach seems to match most intelligent
misspellings and most of those made by children.
Note the order in which these rules are applied are
important, nevertheless please feel free to experiment
with reordering or even adding new rules, after all you
know what kind of strings/names are going to be matched.
Rules for producing the phonetic string
1. Uppercase <cStr>
2. Replace KN with N (Knight)
3. Replace GN with N (Gnome)
4. Replace WR with R (Wright)
5. Replace WH with H if WH is followed by O
6. Replace WH with W if WH isn't follwed by O
(Whately)
7. Replace MC with MK
8. Replace MAC with MK
9. Replace EIGH with AY
(Can't have it not matching *my* name :-)
10. Replace IGHT with ITE (Wright)
11. Replace C with S if followed by E, I or Y
12. Replace C with K if not followed by E, I, Y, H
13. Replace D[JG] with J
14. Replace G with J if followed by E, I, or Y
15. Replace GH with H
16. Replace PH with F
17. Replace Q with KW
18. Replace TI with SH if it is followed by a vowel and
is not at start of a word
19. Replace X with KS
20 Replace Y with I if it is not the first or last
character
21. Replace Z with S
22. Replace MB with M if MB is at end of string (thanks METAPH.PRG)
23. Replace double consonants with just one of 'em
24. Replace AIT with ATE
25. Replace IE at end of word with Y
26. Replace LE with L
27. TERN at end of word gets replaced with TN
28. EVE is replaced with EFE
29 Replace the schwa sound with "" if succeeded by
R, L, M, N
30. Replace SCH with SH
31. ARY, IRY, ORY, ERY all get replaced with RY if
at end of word
32. Replace OO with U
33. Replace OI with OY
34. Remove vowels at end of word
35. Replace all vowel groups with just the first
vowel in the group (you can try last as well)
Examples:
use PERSONS // assume a personnel table
index on GT_fonetix(PERSONS->LAST_NAME) to LASTNAME
seek GT_fonetix("Leighton")
? found(), PERSONS_LAST_NAME // .T., Leighton
seek GT_fonetix("Layton")
? found(), PERSONS->LAST_NAME // .T., Leighton
Also compile with -DTEST
$REFERENCES$
.EXE Magazine Vol 4, Issue 3
Soundex()
METAPH.PRG in nanfor.lib
Source: FONETIX.PRG
Author: Andy M Leighton