Re: Help with Soundex code..
Posted in 1996
Help with Soundex code.. 17-Jan-1996 Hi friend, I found this one, hope you can use it: /*************************************************************************** ** soundex Transform the argument into a code that tends to bring ** together all variants of the same name. ** ** soundex("Poul") = P400 ** soundex("Paul") = P400 ** soundex("Peter") = P360 ** soundex("Peder") = P360 ** ** The method was originally developed by Margaret K. Odell ** and Robert C. Russell. ** ** Retain the first letter of the name, and drop all ** occurrences of a, e, h, i, o, u, w and y in other positions. ** ** Assign the following numbers to the remaining letters after ** the first: ** ** b,f,p,v -> 1 l -> 4 ** c,g,j,k,q,s,x,z -> 2 m,n -> 5 ** d,t -> 3 r -> 6 ** ** If two or more letters with the same code were adjacent in ** the original name, omit all but the first. ** ** Convert to the form "letter, digit, digit, digit" by adding ** trailingg zeros (if there are less than three digits), ** or by droppingg rightmost digits (if there are more than ** three). ** ***************************************************************************/ #include <ctype.h> #define SOUNDEXLEN 4 char *soundex(original_name) char *original_name; { static char mapstring[] = "01230120022455012623010202"; static char strbuffer[SOUNDEXLEN+1]; register int index; register char mapch, upperch, pch = '0'; strcpy(strbuffer,"Z000"); for (index = 0; *original_name && index < SOUNDEXLEN; original_name++) if (isalpha(*original_name)) { upperch = toupper(*original_name); mapch = mapstring[upperch-'A']; if (index == 0 || (mapch != '0' && mapch != pch)) { strbuffer[index] = index ? mapch : upperch; index++; } pch = mapch; } return(strbuffer); } Regards ----------------------------------------------------------------- Databaseadministrator Poul Pedersen Kuwait Petroleum (Danmark) A/S Hummeltoftevej 49 Mail: pp@q8.dk 2830 Virum Voice: +45 45 98 45 94 Denmark Fax: +45 45 83 16 95 ----------------------------------------------------------------- >Hi friends, > >I am looking for the Informix code written for Soundex example. >I know it exists, b'caz someone saw it 3 yrs back on internet. >can someone help me with this. > >thanks... > > >-- >dharmesh >-- >When all other means of communication fail, Try Silence. >==============================================+==============