NSString *z = [NSString stringWithFormat:@"#%@",stringValue];
   NSLog(@"soundexString: %@", [z soundexString]);
   NSLog(@"soundexString2: %@", [stringValue soundexString]);
   NSLog(@"soundexString3: %@", [@"#Face" soundexString]);
   NSLog(@"soundexString4: %@", [@"Face" soundexString]);

   BOOL test = [z soundsLikeString:@"#Face"];
   NSLog(@"sounds like \"Face\": %d", test);

For "Pace" used as stringValue...

soundexString: #120
soundexString2: p200
soundexString3: #120
soundexString4: f200
sounds like "Face": 1

On Wed, Jul 6, 2011 at 2:46 PM, Greg Guerin <glgue...@amug.org> wrote:
> Eric E. Dolecki wrote:
>
>> http://www.cocoadev.com/index.pl?NSStringSoundex
>>
>> However, when I tried it out I get strange results...
>>
>> //someString is set to different strings each time tested
>> BOOL test = [someString soundsLikeString:@"Face"];
>> NSLog(@"sounds like Face: %d",test);
>>
>> Place = 0
>> Ace = 0
>> Mace = 0
>> Fake = 1
>> Testing = 0
>> Brake = 0
>>
>> It would seem something is off to get negatives on Place, Ace & Mace.
>
>
> There's this comment in the -soundexString method:
>
>         Replace consonants with digits as follows (but do not change the
> first letter):
>         b, f, p, v => 1
>         c, g, j, k, q, s, x, z => 2
>         d, t => 3
>         l => 4
>         m, n => 5
>         r => 6
>         Collapse adjacent identical digits into a single digit of that
> value.
>         Remove all non-digits after the first letter.
>         Return the starting letter and the first three remaining digits.
If
> needed, append zeroes to make it a letter and three digits.
>
> Assuming the code works as the comment says, and you should read the code
to
> confirm this, then it doesn't change the first letter.  So it seems to me
> that "Face" won't match place, ace, or mace.
>
> Maybe you could print the value of the -soundexString method instead of
> blindly relying on the boolean of soundsLikeString:.
>
>  -- GG
>
> _______________________________________________
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/edolecki%40gmail.com
>
> This email sent to edole...@gmail.com
>
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to