Glench / fuzzyset.js

fuzzyset.js - A fuzzy string set for javascript

Home Page:http://glench.github.io/fuzzyset.js/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to assign priority to every time in the array

slidenerd opened this issue · comments

Lets say I had an array
['btc', 'ltc']

Person searched 'tc' i want btc to come before ltc, how do we do that

Thanks in advance

Personally, I would have a separate array with the terms you want listed by priority. When fuzzyset returns matches, I would check them against that array and return the ones that you'd like to prioritize. To do this, you can iterate over the prioritized array and check if each result is in the fuzzyset array (if you have a lot of items this might be slow, though).

You can also play around with the gram sizes and levenshtein distance parameters in the constructor to FuzzySet. Play around with it here and maybe you'll find some parameters that make your specific use case work better: http://glench.github.io/fuzzyset.js/viz/