home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 18 REXX
/
18-REXX.zip
/
soundex.cmd
< prev
next >
Wrap
OS/2 REXX Batch file
|
1994-08-16
|
4KB
|
115 lines
/* */
/*
Soundex.cmd : A REXX program that takes a name and reduces it to a
token based on the fact that some letters seem to 'sound' alike. It
was used in a name search for a corporate mail pilot based on a REXX
Gopher server and DB2/2. The results of this routine were stored in the
database along with the name.
usage is : SOUNDEX nnnnnnn ddd
where: nnnnnnn is the name to be tokenized
: ddd is the debug flag Y or Yes displays intermediate
steps
N or No doesn't display anything.
: SOUNDEX
displays this text.
Command entered Returns
=============== =========
Example : SOUNDEX BILL Y B44
: SOUNDEX BILLY Y B44
: SOUNDEX BILLIE Y B44
: SOUNDEX BILLY-RAY B446
: SOUNDEX LORI Y L4
: SOUNDEX LAURIE Y L4
It only 'works' for english although you could tailor it to
another language by re-weighting the tokens. I have also used
it by converting a substring and matching it using a LIKE in
DB2/2.
Authors:Bill Dickenson/Valerie Dickenson
Random Software
118 North Dillwyn Rd
Newark, De 19711
(302) 737-9123
No warrenty expressed or implied. It may not work at all for you
but could be interesting. If you think up some improvements on this
I'd appreciate seeing a re-post.
*/
YES = 'Y'; NO = 'N';NULL = ''
Alpha = xrange('A','Z')
AllChars = Alpha||xrange('00'x, 'FF'x)
dlen = 25
arg in_name debug .
if strip(in_name) = NULL
then signal showhelp
debug = translate(substr(debug,1,1))
if debug <> YES then debug = NO
name.0 = NULL
name.1 = translate(in_name) /* Make it all upper case */
fchar = substr(name.1,1,1) /* Take the first character */
/* Must be alpha */
name.2 = substr(name.1,2) /* Get rest of name */
/* Eliminate AEHIOUWY from string. Keeps the sound simple */
name.2 = STRIP(translate(name.2,,'AEHIOUWY'))
/* dump non-alpha characters */
/* Thanks to Tom Bridgman, Watson Systems Engineering Services (OS/2)
for clearing up some points around translate and for suggesting
xrange to create Alpha and AllChars
*/
name.3 = name.2
rc = verify(name.2,alpha)
if rc <> 0
then do
name.0 = 'Special Characters found'
name.3 = NULL
name.22 = translate(name.2, Alpha, AllChars)
wordloop = words(name.22)
do x = 1 to wordloop
name.3 = name.3||word(name.22,x)
end
end
/* create the weights and create the string */
name.4 = translate(name.3,'1111','BFPV')
name.4 = translate(name.4,'22222222','CGJKQSXZ')
name.4 = translate(name.4,'33','DT')
name.4 = translate(name.4,'4','L')
name.4 = translate(name.4,'55','MN')
name.4 = translate(name.4,'6','R')
name.5 = fchar||name.4
if debug = YES
then do
say Left('Input was ',dlen) in_name
say left('Convert upper case',dlen) name.1
say Left('First letter',dlen) fchar
say left('Drop vowels',dlen) name.2
if name.0 <> NULL then say left('Drop special characters',dlen) name.3
say left('Tokenize rest',dlen) name.4
say left('Build Result',dlen) name.5
end
return(name.5)
showhelp:
do x = 9 to 20
say sourceline(x)
end
say
do x = 31 to 36
say sourceline(x)
end
return(0)