fuzzy-search
fuzzy-search copied to clipboard
Getting multiple results?
Hello, this package is working very well for me, but instead of just showing "mostSimilarString" I'd like to show the most similar strings (plural). Specifically, I'm searching a list of contacts and I'd love to say "I don't see John Smith, did you mean "jane smith, jon smith, john myth, joan smith, jimmy smith"... is there a way to get multiple results out of this?
@jasonnmark it's possible, but I'm super-busy with other things. You can clone repository into your application's /packages/
directory (and then meteor remove perak:fuzzy-search
and meteor add perak:fuzzy-search
), and then you will use package locally. Try to add that feature, implement mostSimilarStrings
function similar to mostSimilarString
here: https://github.com/perak/fuzzy-search/blob/master/lib/fuzzy-search.js#L75 but return array instead of single string (in this line https://github.com/perak/fuzzy-search/blob/master/lib/fuzzy-search.js#L122 if string is "close enough" I mean have small enough distance, then add it to resulting array and return that array at the end of the function).
Please let me know if you succeed and feel free to send me a pull request.
:+1:
Thanks. This will be a stretch for me but I'm going to give it a go.
Jason Sent from my spacePhone
On Apr 22, 2016, at 4:48 PM, Petar Korponaić [email protected] wrote:
@jasonnmark it's possible, but I'm super-busy with other things. You can clone repository into your application's /packages/ directory (and then meteor remove perak:fuzzy-search and meteor add perak:fuzzy-search), and then you will use package locally. Try to add that feature, implement mostSimilarStrings function similar to mostSimilarString here: https://github.com/perak/fuzzy-search/blob/master/lib/fuzzy-search.js#L75 but return array instead of single string (in this line https://github.com/perak/fuzzy-search/blob/master/lib/fuzzy-search.js#L122 if string is "close enough" I mean have small enough distance, then add it to resulting array and return that array at the end of th e function).
Please let me know if you succeed and feel free to send me a pull request.
— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub
Hello,
I did this, if you are interested:
I kept all the original code intact, I just did a push for each word:
{
minDistance = dist;
bestWord = originalCandidate;
results.push({bestWord:bestWord, minDistance:minDistance});
}
...
return results;
Thanks!