• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Approaches for this Matching Problem?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Approaches for this Matching Problem?


  • Subject: Re: Approaches for this Matching Problem?
  • From: Ken Thomases <email@hidden>
  • Date: Sun, 21 Jun 2009 23:35:17 -0500

On Jun 21, 2009, at 11:02 PM, Jerry Krinock wrote:

Given the numbers in your post, "3-5", "250" and "several", I'd say you should just split the phrase into words, write an outer loop for(words in phraseWords), an inner loop for(tag in tags), and inside it all compare using -isEqualToString, breaking when found. "Just do it."

I would suggest making an NSSet from the tags, and using - containsObject: rather than the inner loop. Not necessarily for speed, although it would probably be faster, but just because it's easier and simpler. Since the tags set isn't changing frequently, you can keep the set around persistently, updating it on the infrequent occasions that it's necessary. So, you don't need to build and tear down the set for each phrase matching operation.



Only thing that might require a little digging -- I believe that there is probably a "correct" way to split a phrase into a set or array of words which will work for non-Western languages. - [NSString componentsJoinedByString:@" "] would be a cheesy solution.

The other problem is doing the string matching in a sensible way. You probably don't want the usual test for equality which is a literal match. It's sensitive to case and to differences in precomposed/ decomposed characters, etc.


To do that with NSSet would require you to wrap your strings in a custom class which overrides -isEqual: and -hash:. That runs counter to the simplicity arguing for NSSet. It may end up, after all, that just enumerating the strings and using -compare:options: would be simpler.

Regards,
Ken

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
This email sent to email@hidden


References: 
 >Approaches for this Matching Problem? (From: Steve Cronin <email@hidden>)
 >Re: Approaches for this Matching Problem? (From: Jerry Krinock <email@hidden>)

  • Prev by Date: Re: How to fill rectangle under vertical scroller?
  • Next by Date: Amount of Arguments per Method
  • Previous by thread: Re: Approaches for this Matching Problem?
  • Next by thread: Re: Approaches for this Matching Problem?
  • Index(es):
    • Date
    • Thread