Link | pk_soundex |
Author | Pier Kuipers |
Category | Database |
Version | 8.x |
License | Public Domain |
Posted | 10 Jan 2006 |
Updated | 12 Jan 2011 |
More by this author... |
Based on the NARA Soundex Guide (http://www.archives.gov/research_room/genealogy/census/soundex.html) The soundex is a coded surname (last name) index based on the way a surname sounds rather than the way it is spelled. Surnames that sound the same, but are spelled differently, like SMITH and SMYTH, have the same code and are filed together. The soundex coding system was developed so that you can find a surname even though it may have been recorded under various spellings. Every soundex code consists of a letter and three numbers, such as W-252. The letter is always the first letter of the surname. The numbers are assigned to the remaining letters of the surname according to the soundex guide. Zeroes are added at the end if necessary to produce a four-character code. Additional letters are disregarded.
Modified Jan 2011 at the suggestion of Sidney San Martín to include -copy reference.
Usage: [pk_soundex()] Example: [pk_soundex('Washington')] -> W252
Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.
if(!(lasso_tagexists('pk_soundex'))); define_tag('pk_soundex', -required='myString', -copy); if((#myString -> length) > 0); #myString -> uppercase; local('myStringArray' = ((#myString) -> split:'')); local('mySoundexCode'=(#myStringArray -> get:1)); local('fullSoundexCode'=(string)); if(('ËçåÌ®') >> #mySoundexCode); #mySoundexCode = 'A'; else(('') >> #mySoundexCode); #mySoundexCode = 'S'; else(('éæè') >> #mySoundexCode); #mySoundexCode = 'E'; else(('íêëì') >> #mySoundexCode); #mySoundexCode = 'I'; else(('') >> #mySoundexCode); #mySoundexCode = 'N'; else(('îïͯÎ') >> #mySoundexCode); #mySoundexCode = 'O'; else(('ôòó') >> #mySoundexCode); #mySoundexCode = 'U'; /if; local('thisSoundexCode'=(string)); local('previousCharacter'=(string)); local('previousSoundexCode'=(string)); iterate(#myStringArray, local:'temp'); if(loop_count != 1); #previousCharacter = (#myStringArray -> get((loop_count) - 1)); /if; if(#fullSoundexCode -> length > 0); local('previousSoundexCode'=(#fullSoundexCode -> split('') -> get((#fullSoundexCode -> length)))); else; local('previousSoundexCode'=('')); /if; if(((string_findregexp(#temp, -find='B|F|P|V')) -> size) > 0); #thisSoundexCode = '1'; else(((string_findregexp(#temp, -find='C|G|J|K|Q|S|X|Z||§')) -> size) > 0); #thisSoundexCode = '2'; else(((string_findregexp(#temp, -find='D|T')) -> size) > 0); #thisSoundexCode = '3'; else(((string_findregexp(#temp, -find='L')) -> size) > 0); #thisSoundexCode = '4'; else(((string_findregexp(#temp, -find='M|N|')) -> size) > 0); #thisSoundexCode = '5'; else(((string_findregexp(#temp, -find='R')) -> size) > 0); #thisSoundexCode = '6'; else(((string_findregexp(#temp, -find='B|F|P|V|C|G|J|K|Q|S|X|Z|D|T|L|M|N|R')) -> size) == 0); #thisSoundexCode = ''; /if; if(#thisSoundexCode != ''); #fullSoundexCode += #thisSoundexCode; else; #fullSoundexCode += 'Z'; /if; if(loop_count != 1); if((#thisSoundexCode != #previousSoundexCode)); if(#temp != #previousCharacter); #mySoundexCode += #thisSoundexCode; /if; /if; /if; if(#mySoundexCode -> length > 3); Loop_Abort; /if; /iterate; if(#mySoundexCode -> length < 4); local('x'=(4 - ((#mySoundexCode -> length)))); Loop(#x); #mySoundexCode += '0'; /Loop; /if; return(#mySoundexCode); else; return('0000'); /if; /define_tag; /if;
©LassoSoft Inc 2015 | Web Development by Treefrog Inc | Privacy | Legal terms and Shipping | Contact LassoSoft