Ken;

Thanks as always for a thought-provoking and thorough response!

1) I haven't given up on those Tiger users yet...

2) I don't see how looping on the 'words' in thePhrase would change the 'ham' issue you raise - it would still match either on the word or the phrase.
Am I missing something?
        
3) The actual tags in this particular context are extensive enough that this 'ham-confusion' is pretty unlikely and could be easily remedied by the user's management of the tag list... [e.g. service, management, institute] -- I know there remains the root forms issue but let's not drag that issue in here

Steve


On Jun 22, 2009, at 12:52 PM, Ken Thomases wrote:

On Jun 22, 2009, at 3:10 AM, Steve Cronin wrote:

So I've been pondering and testing...

1) Why would I have to bust up/loop on thePhrase?

BUT in my case I don't care where, what word or how often - I just want to know IF a tag occurs in thePhrase!!

Then you shouldn't refer to "words". If you just care if any of a set of strings appear in a given string, that's a different question.

If one of your tags is "ham", do you want it to match a phrase containing "shame"?


- (BOOL) containsTag:(NSString *)thePhrase {
        BOOL tagFound = NO;
        NSString  *tag;
NSEnumerator *tagEnum = [tags objectEnumerator]; //tags is an NSSet instance variable built from Core Data
        while ((tag=[tagEnum nextObject])!=nil) {
if ([thePhrase rangeOfString:tag options:NSCaseInsensitiveSearch].location!=NSNotFound) {
                        tagFound = YES; break;
                }
        }
        return tagFound;
}

If you can target Leopard or later, you can simplify this even more by using "for (NSString* tag in tags) ...". It's more efficient, too.

Regards,
Ken


_______________________________________________

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