--- a/PhoneticStringUtilities.st Tue Aug 11 18:49:03 2009 +0200
+++ b/PhoneticStringUtilities.st Tue Aug 11 18:50:07 2009 +0200
@@ -246,56 +246,59 @@
(read Knuth or search the web if you dont know what a soundex code is).
Caveat: 'similar sounding words' means: 'similar sounding in english'."
- |inStream codeStream ch last lch codeLength codes code lastCode|
-
- inStream := aString readStream.
- inStream skipSeparators.
- inStream atEnd ifTrue:[
- ^ nil
- ].
-
- ch := inStream next.
- ch isLetter ifFalse:[
- ^ nil
- ].
- codeLength := 0.
-
- codes := Dictionary new.
- codes atAll:'bpfv' put:$1.
- codes atAll:'cskgjqxz' put:$2.
- codes atAll:'dt' put:$3.
- codes atAll:'l' put:$4.
- codes atAll:'nm' put:$5.
- codes atAll:'r' put:$6.
+ ^ (SoundexStringComparator new phoneticStringsFor:aString) first
- codeStream := WriteStream on:(String new:4).
- codeStream nextPut:(ch asUppercase).
- last := ch asLowercase.
- lastCode := codes at:last ifAbsent:nil.
-
- [inStream atEnd] whileFalse:[
- ch := inStream next.
- lch := ch asLowercase.
- lch = last ifFalse:[
- last := lch.
-
- code := codes at:lch ifAbsent:nil.
- (code notNil and:[ code ~= lastCode]) ifTrue:[
- codeLength < 3 ifTrue:[
- codeStream nextPut:code.
- codeLength := codeLength + 1.
- codeLength > 3 ifTrue:[^ codeStream contents].
- ].
- ].
- lastCode := code.
- ]
- ].
- [ codeLength < 3 ] whileTrue:[
- codeStream nextPut:$0.
- codeLength := codeLength + 1.
- ].
-
- ^ codeStream contents
+"/ old code - now use code in private class...
+"/ |inStream codeStream ch last lch codeLength codes code lastCode|
+"/
+"/ inStream := aString readStream.
+"/ inStream skipSeparators.
+"/ inStream atEnd ifTrue:[
+"/ ^ nil
+"/ ].
+"/
+"/ ch := inStream next.
+"/ ch isLetter ifFalse:[
+"/ ^ nil
+"/ ].
+"/ codeLength := 0.
+"/
+"/ codes := Dictionary new.
+"/ codes atAll:'bpfv' put:$1.
+"/ codes atAll:'cskgjqxz' put:$2.
+"/ codes atAll:'dt' put:$3.
+"/ codes atAll:'l' put:$4.
+"/ codes atAll:'nm' put:$5.
+"/ codes atAll:'r' put:$6.
+"/
+"/ codeStream := WriteStream on:(String new:4).
+"/ codeStream nextPut:(ch asUppercase).
+"/ last := ch asLowercase.
+"/ lastCode := codes at:last ifAbsent:nil.
+"/
+"/ [inStream atEnd] whileFalse:[
+"/ ch := inStream next.
+"/ lch := ch asLowercase.
+"/ lch = last ifFalse:[
+"/ last := lch.
+"/
+"/ code := codes at:lch ifAbsent:nil.
+"/ (code notNil and:[ code ~= lastCode]) ifTrue:[
+"/ codeLength < 3 ifTrue:[
+"/ codeStream nextPut:code.
+"/ codeLength := codeLength + 1.
+"/ codeLength > 3 ifTrue:[^ codeStream contents].
+"/ ].
+"/ ].
+"/ lastCode := code.
+"/ ]
+"/ ].
+"/ [ codeLength < 3 ] whileTrue:[
+"/ codeStream nextPut:$0.
+"/ codeLength := codeLength + 1.
+"/ ].
+"/
+"/ ^ codeStream contents
"
PhoneticStringUtilities soundexCodeOf:'claus'
@@ -2662,5 +2665,5 @@
!PhoneticStringUtilities class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic2/PhoneticStringUtilities.st,v 1.4 2009-08-11 16:49:03 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic2/PhoneticStringUtilities.st,v 1.5 2009-08-11 16:50:07 cg Exp $'
! !