Richard MacLemale wrote:
> I know that several people are working on their own on a
> spell check engine for MetaCard.
[snip]
Its a good algorithm, but I think it could be simplified a bit.
Try:
function soundex thisWord
-- returns <thisWord> less any vowels, near-vowels and
-- duplicate characters, allowing them in the 1st character
-- eg soundex("abracadddabra") -> "abrcdbr"
put char 1 of thisWord into prevChar
put prevChar into soundexString
repeat with j = 2 to the length of thisWord
put char j of thisWord into c
if c is not in ("aeiouyh" & prevChar)
then put c after soundexString
put c into prevChar
end repeat
return soundexString
end soundex
Note also that when you are building your dictionary, you don't need to
call it a word at a time. Spaces, commas and returns aren't removed by
the function, so to build your dictionary you can use something like:
put soundex(field "Dictionary") into field "Soundex Dictionary"
(although if you do this, I'd recommend putting some sort of progress
indicator into the soundex function).
Hope this is useful.
--
Steven D'Aprano
==========================================
M.B. Sales Pty Ltd Ph: +61 3 9460-5244
A.C.N. 005-964-796 Fax: +61 3 9462-1161
This is the MetaCard mailing list.
Archives: http://www.mail-archive.com/metacard%40lists.best.com/
Info: http://www.xworlds.com/metacard/mailinglist.htm