REVO2700soundex#@AT/* This stack is 2009, 2012 by Devin Asay and Brigham Young University. Based on the public domain soundex algorithm. */ --> Handlers function soundex pWord put doSubstitutions(pWord) into tSoundexString # soundex algorithm # strip out all non-alpha characters put stripNonAlpha(tSoundexString) into tSoundexString # keep first letter of word put char 1 of tSoundexString into tChar1 # Make letter to number substitutions put char 2 to -1 of tSoundexString into tRestOfWord set the itemdel to comma put empty into tNumericStr repeat for each char tChar in tRestOfWord switch case tChar is among the items of "a,e,i,o,u,h,w,y" put 0 after tNumericStr break case tChar is among the items of "b,f,p,v" put 1 after tNumericStr break case tChar is among the items of "c,g,j,k,q,s,x,z" put 2 after tNumericStr break case tChar is among the items of "d,t" put 3 after tNumericStr break case tChar is among the items of "l" put 4 after tNumericStr break case tChar is among the items of "m,n" put 5 after tNumericStr break case tChar is among the items of "r" put 6 after tNumericStr break end switch end repeat # remove pairs of digits repeat with x= 1 to 6 replace (x & x) with x in tNumericStr end repeat # remove all zeros replace "0" with empty in tNumericStr # pad with trailing zeros as needed repeat while length(tNumericStr) < 3 put "0" after tNumericStr end repeat return char 1 to 4 of (toUpper(tChar1 & tNumericStr)) end soundex function doSubstitutions pModWord put pModWord into tModWord # handle exceptions ## a/ough --> f put substituteGHExceptions(tModWord,tExceptions) into tModWord ## consonant combination substitutions replace "dg" with "g" in tModWord replace "gh" with "h" in tModWord if tModWord begins with "gn" then put "n" into char 1 to 2 of tModWord if tModWord ends with "gn" and char -3 of tModWord is among the chars of "aeiouy" \ then put "n" into char -2 to -1 of tModWord # handle kn if "kn" is in tModWord then # filter out instances of -"kness" put offset("kn",tModWord) into tPos if char tPos + 1 to tPos + 4 of tModWord is "ness" then replace char tPos + 1 to tPos + 4 of tModWord with "*" in tModWord end if replace "kn" with "n" in tModWord replace "*" with "ness" in tModWord end if # handle c + i,e,y if tModWord begins with "c" then if char 2 of tModWord is among the items of "e,i,y" and NOT (tModWord begins with "celt") then put "s" into char 1 of tModWord else put "k" into char 1 of tModWord end if end if # various consonant combinations replace "ph" with "f" in tModWord if tModWord begins with "ps" then put "s" into char 1 to 2 of tModWord if tModWord begins with "pf" then put "f" into char 1 to 2 of tModWord if tModWord ends with "mb" then put "m" into char -2 to -1 of tModWord replace "tch" with "ch" in tModWord return tModWord end doSubstitutions function substituteGHExceptions pWordToCheck put "cough,draught,enough,laugh,rough,tough,trough" into tExceptions set the itemdel to comma repeat for each item tExcepWord in tExceptions if tExcepWord is in pWordToCheck then -- if tExcepWord is "draught" then -- replace "ght" with "ft" in pWordToCheck -- else replace "gh" with "f" in pWordToCheck exit repeat end if end repeat return pWordToCheck end substituteGHExceptions function stripNonAlpha pStr put empty into tStrippedStr repeat for each char tChar in pStr if isALetter(tChar) then put tChar after tStrippedStr end repeat return tStrippedStr end stripNonAlpha private function isALetter pChar get charToNum(pChar) if (it > 65 and it < 90) or (it > 96 and it < 123) then return true else return false end if end isALetter 5SSpelling Matching with Soundex  ULucida GrandecREVGeometryCachestackID1014 cREVGeneralbreakpointconditionsscripteditorvscroll0 revUniqueID 1259778071117 breakpointsbreakpointstatesstackfileversion2.7 @ tRevGeneral tRevUniqueID 1259778070220 cREVGeneralscripteditorvscroll0 revUniqueID 1259778069218cREVGeometryCacheIDs 124465431137810081244654282222100612446708783461014124465431136710071244670525228101212446541911121004124467060801210131244661890787101012446705069381011cREVGeometrycachetotal9order   targetWord)h|( cREVGeneral revUniqueID 1244654191112  jelly targetWordLbl *l cREVTable currentviewWord to match: cREVGeneral revUniqueID 1244654282222 Word to match:  typedWord)h|X cREVGeneral revUniqueID 1244654311367  jello  typedWordLbl Zl cREVTable currentviewWord as typed: cREVGeneral revUniqueID 1244654311378 Word as typed: checkmatchew?on mouseUp put soundex(fld "targetWord") into tTargetWdSndx put tTargetWdSndx into fld "targetSndex" put soundex(fld "typedWord") into tTypedWdSndx put tTypedWdSndx into fld "typedSndex" if tTargetWdSndx = tTypedWdSndx then put "Yes" into fld "match" else put "No" into fld "match" end mouseUp r4Do They Match? tRevGeneral tRevUniqueID 1244661891797 cREVGeneralscripteditorvscroll0 revUniqueID 1244661890787scripteditorselection0  targetSndex)h<(D cREVGeneral revUniqueID 1244670506938  J400  typedSndex)h<XD cREVGeneral revUniqueID 1244670525228  J400resetewon mouseUp put empty into fld "targetWord" put empty into fld "targetSndex" put empty into fld "typedWord" put empty into fld "typedSndex" put empty into fld "match" end mouseUp ~B2Reset tRevGeneral tRevUniqueID 1244670609025 cREVGeneral revUniqueID 1244670608012scripteditorvscroll0scripteditorselection180 match)h;D cREVGeneral revUniqueID 1244670878346  Yes revOnline | RunRev