fabiomcosta / mootools-meio-autocomplete

A complete mootools Autocomplete plugin
http://www.meiocodigo.com/projects/meio-autocomplete/
32 stars 14 forks source link

[Enhancement] Autocompletion by similarity #3

Open SunboX opened 14 years ago

SunboX commented 14 years ago

Could you implement a option to get autocompletion by similarity? Like this:

http://phpjs.org/functions/levenshtein:463

Would be really cool! Maybe a combination from current algorithm (first chars matching) and the levenshtein algorithm is also possible.

SunboX commented 14 years ago

One more: approximated string matching

http://www.mutah.edu.jo/eprint/index.php/science/information-technology/67-a-fast-approximate-string-searching-algorithm.html

fabiomcosta commented 14 years ago

Thats very interesting. Maybe a demo showing how to do it would be cool, not something builtin. I'll try it out. Thanks!

fabiomcosta commented 14 years ago

I'm interested on your application, can you explain it?

SunboX commented 14 years ago

Yes, i´m looking for an autocompletion, that suggests the following:

I´m typing: Mac Donalds Suggests:

McDonald´s Mac Doctors Mac Fastfood

A normal autocompletion would only show the last two suggests. But that´s wrong in this case. The order of the suggested words should be the levenshtein index for similarity. Lower index on top.

SunboX commented 14 years ago

In my case the autocompletion list would be prefilled with location names around a persons location. And if that person types the name of a location, it should try to get the name the person is looking for.

SunboX commented 14 years ago

This is what i want to get (not tested yet!):

http://jsfiddle.net/SunboX/t5f5T/

SunboX commented 14 years ago

Is it possible to modify filter behavior, that they return integers instead of booleans? Like this:

http://jsfiddle.net/SunboX/Z69jS/

greetings, André

SunboX commented 14 years ago

So we could sort the filtered items by best fitting. ;o)

fabiomcosta commented 14 years ago

cool stuff, im thinking about this to make it in a way that can be very generic, that you could define any kind of sorting on your options...

fabiomcosta commented 14 years ago

Hey man you can use the similarity functionality without needing to change anything... look at this and tell what you think: http://jsfiddle.net/7cUgF/1/ I've reduced a little the levenshtein function.