Open mongoose54 opened 10 years ago
A) for large data sets, consider organizing your strings in a trie. This will let you to return less results and thus less processing done by the actual text field. More info here: http://en.m.wikipedia.org/wiki/Trie
B) The results are sorted in order of the smallest edit distance to the input string. If you do not want the order of the strings you send to be modified, there may be a way to turn this behavior off with a property, but it's been a while so I don't remember if I implemented that. I'm out posting from my phone right now so I can't check too well.
C) I'll have to think about this some more.
D) Ranking a suggestion's likelyhood is achieved by associating a weighted number for each string. The larger the weight, the more likely it's the string user intends to type. There are couple ways to implement this. Basically you have to return more than just a simple array of strings, you can extend the MLPAutoCompletion protocol to also provide information on weight or perhaps support a dictionary of strings with NSNumbers associated to them. Then, you will need to change the sorting algorithm so it considers weight.
Hope it helps a bit.
Hi there,
I've been thinking about point C, maybe it can be done in the Class which follows the <MLPAutoCompleteTextFieldDataSource>
protocol.
In the autoCompleteTextField
method, you might be able to split the possibleCompletionForString
parameter into an array, iterate over the results, and for each keyword you reduce the possible completion since you own the NSMutableArray
returned by the method.
Wouldn't that work ?
Possibly, I wasn't too sure what the original goal was.
If a developer would rather sort results on his own, the BOOL property sortAutoCompleteSuggestionsByClosestMatch
should be set to false.
Hi Eddy,
First I wanted to say congrats about the great work with MLPAutoCompleteTextField. I started playing with it recently. So here are my goals:
a) I want to search on a large array of strings. I experimented with 10K and it is not bad (~1sec). Do you have any ideas how to optimize for larger arrays? Perhaps some caching? b) I have already pre-sorted the array. Does it helps? I cannot seem to find in your code if it sorts the array or not. c) How can I change your code so that the search takes place on multiple words?I want to do this because my array contains entries with multiple words. Basically what I want to achieve is this: the user types in one word, the word is matched as it does now, but then when the user types in a second word, then the second word is tried to be matched with the results of the first word. Could you point me to your code? d) Finally you mention that you want to do have some ranking in the array of strings. How could I modify your code to address this?
Once again thank you for your help. Great work!
-Alex