Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get the score between 0.0 and 1.0 #19

Closed
slidenerd opened this issue Dec 23, 2017 · 8 comments
Closed

How to get the score between 0.0 and 1.0 #19

slidenerd opened this issue Dec 23, 2017 · 8 comments

Comments

@slidenerd
Copy link

slidenerd commented Dec 23, 2017

Thanks for the library in the first place! Would super appreciate if you could put an example on how to get results between 0 and 1 or in terms of percentage or whatever works

@slidenerd slidenerd changed the title How to get the percentage score between 0.0 and 1 How to get the score between 0.0 and 1.0 Dec 23, 2017
@farzher
Copy link
Owner

farzher commented Dec 23, 2017

The score doesn't work like that.
It just loses more score for each "mistake".
There's no minimum score besides no match.
And very similar searches will give the worst possible score for having just a single fatal mistake. fuzzysort.single('examples', 'example') gives no match because the s doesn't exist.
But what exactly are you trying to do? Maybe I can help with more details.

@slidenerd
Copy link
Author

slidenerd commented Dec 23, 2017

Thanks for getting back so quickly! Your library was the best out of all the libs fusejs etc
I am trying to correct spelling mistakes in cryptocurrency symbols
Lets say we have coins BTC ETH XRP XMR DGB etc...
A person types BUC by mistake, it should definitely show BTC as the closest match
A person types ETX then we have 2 choices ETH and ETC and both are valid cryptos but it makes more sense to assign ETH since it is more popular in terms of rank than ETC

EDIT 1
I understand that this is an autocomplete library and attempts to look ahead and predict relevant matches but I was wondering if there are any quirks in the library by which I can achieve this. if I type just BT it definitely shows BTC and other relevant options which is superb , the problem happens when i type BTJ and there is no way to find the closest match as BTC

The result below was derived when I typed BT which is pretty awesome!

[ { target: 'BTM',
    _targetLowerCodes: [ 98, 116, 109 ],
    _nextBeginningIndexes: [ 3, 3, 3 ],
    score: -1,
    indexes: [ 0, 1 ],
    obj: null },
  { target: 'BTB',
    _targetLowerCodes: [ 98, 116, 98 ],
    _nextBeginningIndexes: [ 3, 3, 3 ],
    score: -1,
    indexes: [ 0, 1 ],
    obj: null },
  { target: 'BTC',
    _targetLowerCodes: [ 98, 116, 99 ],
    _nextBeginningIndexes: [ 3, 3, 3 ],
    score: -1,
    indexes: [ 0, 1 ],
    obj: null },
  { target: 'BTG',
    _targetLowerCodes: [ 98, 116, 103 ],
    _nextBeginningIndexes: [ 3, 3, 3 ],
    score: -1,
    indexes: [ 0, 1 ],
    obj: null },
  { target: 'BTE',
    _targetLowerCodes: [ 98, 116, 101 ],
    _nextBeginningIndexes: [ 3, 3, 3 ],
    score: -1,
    indexes: [ 0, 1 ],
    obj: null },
  { target: 'BTQ',
    _targetLowerCodes: [ 98, 116, 113 ],
    _nextBeginningIndexes: [ 3, 3, 3 ],
    score: -1,
    indexes: [ 0, 1 ],
    obj: null },
  { target: 'BTU',
    _targetLowerCodes: [ 98, 116, 117 ],
    _nextBeginningIndexes: [ 3, 3, 3 ],
    score: -1,
    indexes: [ 0, 1 ],
    obj: null },
  { target: 'BTS',
    _targetLowerCodes: [ 98, 116, 115 ],
    _nextBeginningIndexes: [ 3, 3, 3 ],
    score: -1,
    indexes: [ 0, 1 ],
    obj: null },
  { target: 'BTX',
    _targetLowerCodes: [ 98, 116, 120 ],
    _nextBeginningIndexes: [ 3, 3, 3 ],
    score: -1,
    indexes: [ 0, 1 ],
    obj: null },
  { target: 'BT1',
    _targetLowerCodes: [ 98, 116, 49 ],
    _nextBeginningIndexes: [ 3, 3, 3 ],
    score: -1,
    indexes: [ 0, 1 ],
    obj: null },
  { target: 'BTG',
    _targetLowerCodes: [ 98, 116, 103 ],
    _nextBeginningIndexes: [ 3, 3, 3 ],
    score: -1,
    indexes: [ 0, 1 ],
    obj: null },
  { target: 'BT2',
    _targetLowerCodes: [ 98, 116, 50 ],
    _nextBeginningIndexes: [ 3, 3, 3 ],
    score: -1,
    indexes: [ 0, 1 ],
    obj: null },
  { target: 'BTM',
    _targetLowerCodes: [ 98, 116, 109 ],
    _nextBeginningIndexes: [ 3, 3, 3 ],
    score: -1,
    indexes: [ 0, 1 ],
    obj: null },
  { target: 'BTA',
    _targetLowerCodes: [ 98, 116, 97 ],
    _nextBeginningIndexes: [ 3, 3, 3 ],
    score: -1,
    indexes: [ 0, 1 ],
    obj: null },
  { target: 'BTCZ',
    _targetLowerCodes: [ 98, 116, 99, 122 ],
    _nextBeginningIndexes: [ 4, 4, 4, 4 ],
    score: -2,
    indexes: [ 0, 1 ],
    obj: null },
  { target: 'BTCR',
    _targetLowerCodes: [ 98, 116, 99, 114 ],
    _nextBeginningIndexes: [ 4, 4, 4, 4 ],
    score: -2,
    indexes: [ 0, 1 ],
    obj: null },
  { target: 'BTCS',
    _targetLowerCodes: [ 98, 116, 99, 115 ],
    _nextBeginningIndexes: [ 4, 4, 4, 4 ],
    score: -2,
    indexes: [ 0, 1 ],
    obj: null },
  { target: 'BTCA',
    _targetLowerCodes: [ 98, 116, 99, 97 ],
    _nextBeginningIndexes: [ 4, 4, 4, 4 ],
    score: -2,
    indexes: [ 0, 1 ],
    obj: null },
  { target: 'BTSR',
    _targetLowerCodes: [ 98, 116, 115, 114 ],
    _nextBeginningIndexes: [ 4, 4, 4, 4 ],
    score: -2,
    indexes: [ 0, 1 ],
    obj: null },
  { target: 'BTCS',
    _targetLowerCodes: [ 98, 116, 99, 115 ],
    _nextBeginningIndexes: [ 4, 4, 4, 4 ],
    score: -2,
    indexes: [ 0, 1 ],
    obj: null },
  { target: 'BTCM',
    _targetLowerCodes: [ 98, 116, 99, 109 ],
    _nextBeginningIndexes: [ 4, 4, 4, 4 ],
    score: -2,
    indexes: [ 0, 1 ],
    obj: null },
  { target: 'BTCD',
    _targetLowerCodes: [ 98, 116, 99, 100 ],
    _nextBeginningIndexes: [ 4, 4, 4, 4 ],
    score: -2,
    indexes: [ 0, 1 ],
    obj: null },
  { target: 'BTBc',
    _targetLowerCodes: [ 98, 116, 98, 99 ],
    _nextBeginningIndexes: [ 4, 4, 4, 4 ],
    score: -2,
    indexes: [ 0, 1 ],
    obj: null },
  { target: 'BTDX',
    _targetLowerCodes: [ 98, 116, 100, 120 ],
    _nextBeginningIndexes: [ 4, 4, 4, 4 ],
    score: -2,
    indexes: [ 0, 1 ],
    obj: null },
  { target: 'BTPL',
    _targetLowerCodes: [ 98, 116, 112, 108 ],
    _nextBeginningIndexes: [ 4, 4, 4, 4 ],
    score: -2,
    indexes: [ 0, 1 ],
    obj: null },
  { target: 'BTWTY',
    _targetLowerCodes: [ 98, 116, 119, 116, 121 ],
    _nextBeginningIndexes: [ 5, 5, 5, 5, 5 ],
    score: -3,
    indexes: [ 0, 1 ],
    obj: null },
  { target: 'BTC2X',
    _targetLowerCodes: [ 98, 116, 99, 50, 120 ],
    _nextBeginningIndexes: [ 4, 4, 4, 4, 5 ],
    score: -3,
    indexes: [ 0, 1 ],
    obj: null },
  { target: 'BTCRED',
    _targetLowerCodes: [ 98, 116, 99, 114, 101, 100 ],
    _nextBeginningIndexes: [ 6, 6, 6, 6, 6, 6 ],
    score: -4,
    indexes: [ 0, 1 ],
    obj: null },
  { target: 'GBT',
    _targetLowerCodes: [ 103, 98, 116 ],
    _nextBeginningIndexes: [ 3, 3, 3 ],
    score: -1001,
    indexes: [ 1, 2 ],
    obj: null },
  { target: 'EBT',
    _targetLowerCodes: [ 101, 98, 116 ],
    _nextBeginningIndexes: [ 3, 3, 3 ],
    score: -1001,
    indexes: [ 1, 2 ],
    obj: null },
  { target: 'HBT',
    _targetLowerCodes: [ 104, 98, 116 ],
    _nextBeginningIndexes: [ 3, 3, 3 ],
    score: -1001,
    indexes: [ 1, 2 ],
    obj: null },
  { target: 'QBT',
    _targetLowerCodes: [ 113, 98, 116 ],
    _nextBeginningIndexes: [ 3, 3, 3 ],
    score: -1001,
    indexes: [ 1, 2 ],
    obj: null },
  { target: 'RBT',
    _targetLowerCodes: [ 114, 98, 116 ],
    _nextBeginningIndexes: [ 3, 3, 3 ],
    score: -1001,
    indexes: [ 1, 2 ],
    obj: null },
  { target: 'QBT',
    _targetLowerCodes: [ 113, 98, 116 ],
    _nextBeginningIndexes: [ 3, 3, 3 ],
    score: -1001,
    indexes: [ 1, 2 ],
    obj: null },
  { target: 'PBT',
    _targetLowerCodes: [ 112, 98, 116 ],
    _nextBeginningIndexes: [ 3, 3, 3 ],
    score: -1001,
    indexes: [ 1, 2 ],
    obj: null },
  { target: 'DBTC',
    _targetLowerCodes: [ 100, 98, 116, 99 ],
    _nextBeginningIndexes: [ 4, 4, 4, 4 ],
    score: -1002,
    indexes: [ 1, 2 ],
    obj: null },
  { target: 'SBTC',
    _targetLowerCodes: [ 115, 98, 116, 99 ],
    _nextBeginningIndexes: [ 4, 4, 4, 4 ],
    score: -1002,
    indexes: [ 1, 2 ],
    obj: null },
  { target: 'UBTC',
    _targetLowerCodes: [ 117, 98, 116, 99 ],
    _nextBeginningIndexes: [ 4, 4, 4, 4 ],
    score: -1002,
    indexes: [ 1, 2 ],
    obj: null },
  { target: 'XBTS',
    _targetLowerCodes: [ 120, 98, 116, 115 ],
    _nextBeginningIndexes: [ 4, 4, 4, 4 ],
    score: -1002,
    indexes: [ 1, 2 ],
    obj: null },
  { target: 'LBTC',
    _targetLowerCodes: [ 108, 98, 116, 99 ],
    _nextBeginningIndexes: [ 4, 4, 4, 4 ],
    score: -1002,
    indexes: [ 1, 2 ],
    obj: null },
  { target: 'IBTC',
    _targetLowerCodes: [ 105, 98, 116, 99 ],
    _nextBeginningIndexes: [ 4, 4, 4, 4 ],
    score: -1002,
    indexes: [ 1, 2 ],
    obj: null },
  { target: 'EBTC',
    _targetLowerCodes: [ 101, 98, 116, 99 ],
    _nextBeginningIndexes: [ 4, 4, 4, 4 ],
    score: -1002,
    indexes: [ 1, 2 ],
    obj: null },
  { target: 'XBTC21',
    _targetLowerCodes: [ 120, 98, 116, 99, 50, 49 ],
    _nextBeginningIndexes: [ 6, 6, 6, 6, 6, 6 ],
    score: -1004,
    indexes: [ 1, 2 ],
    obj: null },
  { target: 'BET',
    _targetLowerCodes: [ 98, 101, 116 ],
    _nextBeginningIndexes: [ 3, 3, 3 ],
    score: -2001,
    indexes: [ 0, 2 ],
    obj: null },
  { target: 'BOT',
    _targetLowerCodes: [ 98, 111, 116 ],
    _nextBeginningIndexes: [ 3, 3, 3 ],
    score: -2001,
    indexes: [ 0, 2 ],
    obj: null },
  { target: 'BAT',
    _targetLowerCodes: [ 98, 97, 116 ],
    _nextBeginningIndexes: [ 3, 3, 3 ],
    score: -2001,
    indexes: [ 0, 2 ],
    obj: null },
  { target: 'BXT',
    _targetLowerCodes: [ 98, 120, 116 ],
    _nextBeginningIndexes: [ 3, 3, 3 ],
    score: -2001,
    indexes: [ 0, 2 ],
    obj: null },
  { target: 'BIT',
    _targetLowerCodes: [ 98, 105, 116 ],
    _nextBeginningIndexes: [ 3, 3, 3 ],
    score: -2001,
    indexes: [ 0, 2 ],
    obj: null },
  { target: 'BAT',
    _targetLowerCodes: [ 98, 97, 116 ],
    _nextBeginningIndexes: [ 3, 3, 3 ],
    score: -2001,
    indexes: [ 0, 2 ],
    obj: null },
  { target: 'BNT',
    _targetLowerCodes: [ 98, 110, 116 ],
    _nextBeginningIndexes: [ 3, 3, 3 ],
    score: -2001,
    indexes: [ 0, 2 ],
    obj: null },
  { target: 'BBT',
    _targetLowerCodes: [ 98, 98, 116 ],
    _nextBeginningIndexes: [ 3, 3, 3 ],
    score: -2001,
    indexes: [ 0, 2 ],
    obj: null },
  { target: 'BET',
    _targetLowerCodes: [ 98, 101, 116 ],
    _nextBeginningIndexes: [ 3, 3, 3 ],
    score: -2001,
    indexes: [ 0, 2 ],
    obj: null },
  { target: 'BSTY',
    _targetLowerCodes: [ 98, 115, 116, 121 ],
    _nextBeginningIndexes: [ 4, 4, 4, 4 ],
    score: -2002,
    indexes: [ 0, 2 ],
    obj: null },
  { target: 'BITB',
    _targetLowerCodes: [ 98, 105, 116, 98 ],
    _nextBeginningIndexes: [ 4, 4, 4, 4 ],
    score: -2002,
    indexes: [ 0, 2 ],
    obj: null },
  { target: 'PLBT',
    _targetLowerCodes: [ 112, 108, 98, 116 ],
    _nextBeginningIndexes: [ 4, 4, 4, 4 ],
    score: -2002,
    indexes: [ 2, 3 ],
    obj: null },
  { target: 'BITS',
    _targetLowerCodes: [ 98, 105, 116, 115 ],
    _nextBeginningIndexes: [ 4, 4, 4, 4 ],
    score: -2002,
    indexes: [ 0, 2 ],
    obj: null },
  { target: 'BITZ',
    _targetLowerCodes: [ 98, 105, 116, 122 ],
    _nextBeginningIndexes: [ 4, 4, 4, 4 ],
    score: -2002,
    indexes: [ 0, 2 ],
    obj: null },
  { target: 'BSTAR',
    _targetLowerCodes: [ 98, 115, 116, 97, 114 ],
    _nextBeginningIndexes: [ 5, 5, 5, 5, 5 ],
    score: -2003,
    indexes: [ 0, 2 ],
    obj: null },
  { target: 'BITCF',
    _targetLowerCodes: [ 98, 105, 116, 99, 102 ],
    _nextBeginningIndexes: [ 5, 5, 5, 5, 5 ],
    score: -2003,
    indexes: [ 0, 2 ],
    obj: null },
  { target: 'BITOK',
    _targetLowerCodes: [ 98, 105, 116, 111, 107 ],
    _nextBeginningIndexes: [ 5, 5, 5, 5, 5 ],
    score: -2003,
    indexes: [ 0, 2 ],
    obj: null },
  { target: 'BITBTC',
    _targetLowerCodes: [ 98, 105, 116, 98, 116, 99 ],
    _nextBeginningIndexes: [ 6, 6, 6, 6, 6, 6 ],
    score: -2004,
    indexes: [ 0, 2 ],
    obj: null },
  { target: 'BITEUR',
    _targetLowerCodes: [ 98, 105, 116, 101, 117, 114 ],
    _nextBeginningIndexes: [ 6, 6, 6, 6, 6, 6 ],
    score: -2004,
    indexes: [ 0, 2 ],
    obj: null },
  { target: 'BITCNY',
    _targetLowerCodes: [ 98, 105, 116, 99, 110, 121 ],
    _nextBeginningIndexes: [ 6, 6, 6, 6, 6, 6 ],
    score: -2004,
    indexes: [ 0, 2 ],
    obj: null },
  { target: 'BITUSD',
    _targetLowerCodes: [ 98, 105, 116, 117, 115, 100 ],
    _nextBeginningIndexes: [ 6, 6, 6, 6, 6, 6 ],
    score: -2004,
    indexes: [ 0, 2 ],
    obj: null },
  { target: 'BITGOLD',
    _targetLowerCodes: [ 98, 105, 116, 103, 111, 108, 100 ],
    _nextBeginningIndexes: [ 7, 7, 7, 7, 7, 7, 7 ],
    score: -2005,
    indexes: [ 0, 2 ],
    obj: null },
  { target: 'BITSILVER',
    _targetLowerCodes: [ 98, 105, 116, 115, 105, 108, 118, 101, 114 ],
    _nextBeginningIndexes: [ 9, 9, 9, 9, 9, 9, 9, 9, 9 ],
    score: -2007,
    indexes: [ 0, 2 ],
    obj: null },
  { target: 'BRIT',
    _targetLowerCodes: [ 98, 114, 105, 116 ],
    _nextBeginningIndexes: [ 4, 4, 4, 4 ],
    score: -3002,
    indexes: [ 0, 3 ],
    obj: null },
  { target: 'BOAT',
    _targetLowerCodes: [ 98, 111, 97, 116 ],
    _nextBeginningIndexes: [ 4, 4, 4, 4 ],
    score: -3002,
    indexes: [ 0, 3 ],
    obj: null },
  { target: 'BOST',
    _targetLowerCodes: [ 98, 111, 115, 116 ],
    _nextBeginningIndexes: [ 4, 4, 4, 4 ],
    score: -3002,
    indexes: [ 0, 3 ],
    obj: null },
  { target: 'BRAT',
    _targetLowerCodes: [ 98, 114, 97, 116 ],
    _nextBeginningIndexes: [ 4, 4, 4, 4 ],
    score: -3002,
    indexes: [ 0, 3 ],
    obj: null },
  { target: 'BEST',
    _targetLowerCodes: [ 98, 101, 115, 116 ],
    _nextBeginningIndexes: [ 4, 4, 4, 4 ],
    score: -3002,
    indexes: [ 0, 3 ],
    obj: null },
  { target: 'BCPT',
    _targetLowerCodes: [ 98, 99, 112, 116 ],
    _nextBeginningIndexes: [ 4, 4, 4, 4 ],
    score: -3002,
    indexes: [ 0, 3 ],
    obj: null },
  { target: 'USNBT',
    _targetLowerCodes: [ 117, 115, 110, 98, 116 ],
    _nextBeginningIndexes: [ 5, 5, 5, 5, 5 ],
    score: -3003,
    indexes: [ 3, 4 ],
    obj: null },
  { target: 'BLITZ',
    _targetLowerCodes: [ 98, 108, 105, 116, 122 ],
    _nextBeginningIndexes: [ 5, 5, 5, 5, 5 ],
    score: -3003,
    indexes: [ 0, 3 ],
    obj: null },
  { target: 'EBST',
    _targetLowerCodes: [ 101, 98, 115, 116 ],
    _nextBeginningIndexes: [ 4, 4, 4, 4 ],
    score: -4002,
    indexes: [ 1, 3 ],
    obj: null },
  { target: 'EBET',
    _targetLowerCodes: [ 101, 98, 101, 116 ],
    _nextBeginningIndexes: [ 4, 4, 4, 4 ],
    score: -4002,
    indexes: [ 1, 3 ],
    obj: null },
  { target: '8BIT',
    _targetLowerCodes: [ 56, 98, 105, 116 ],
    _nextBeginningIndexes: [ 1, 4, 4, 4 ],
    score: -4002,
    indexes: [ 1, 3 ],
    obj: null },
  { target: 'RBBT',
    _targetLowerCodes: [ 114, 98, 98, 116 ],
    _nextBeginningIndexes: [ 4, 4, 4, 4 ],
    score: -4002,
    indexes: [ 1, 3 ],
    obj: null },
  { target: 'EBIT',
    _targetLowerCodes: [ 101, 98, 105, 116 ],
    _nextBeginningIndexes: [ 4, 4, 4, 4 ],
    score: -4002,
    indexes: [ 1, 3 ],
    obj: null },
  { target: 'NBIT',
    _targetLowerCodes: [ 110, 98, 105, 116 ],
    _nextBeginningIndexes: [ 4, 4, 4, 4 ],
    score: -4002,
    indexes: [ 1, 3 ],
    obj: null },
  { target: 'DBET',
    _targetLowerCodes: [ 100, 98, 101, 116 ],
    _nextBeginningIndexes: [ 4, 4, 4, 4 ],
    score: -4002,
    indexes: [ 1, 3 ],
    obj: null },
  { target: 'GBYTE',
    _targetLowerCodes: [ 103, 98, 121, 116, 101 ],
    _nextBeginningIndexes: [ 5, 5, 5, 5, 5 ],
    score: -4003,
    indexes: [ 1, 3 ],
    obj: null },
  { target: 'BURST',
    _targetLowerCodes: [ 98, 117, 114, 115, 116 ],
    _nextBeginningIndexes: [ 5, 5, 5, 5, 5 ],
    score: -4003,
    indexes: [ 0, 4 ],
    obj: null },
  { target: 'OBITS',
    _targetLowerCodes: [ 111, 98, 105, 116, 115 ],
    _nextBeginningIndexes: [ 5, 5, 5, 5, 5 ],
    score: -4003,
    indexes: [ 1, 3 ],
    obj: null },
  { target: 'RUBIT',
    _targetLowerCodes: [ 114, 117, 98, 105, 116 ],
    _nextBeginningIndexes: [ 5, 5, 5, 5, 5 ],
    score: -6003,
    indexes: [ 2, 4 ],
    obj: null },
  { target: 'RUSTBITS',
    _targetLowerCodes: [ 114, 117, 115, 116, 98, 105, 116, 115 ],
    _nextBeginningIndexes: [ 8, 8, 8, 8, 8, 8, 8, 8 ],
    score: -10006,
    indexes: [ 4, 6 ],
    obj: null },
  total: 86 ]

BTJ gives a total count of 0 though [ total: 0 ] hence the question

@farzher
Copy link
Owner

farzher commented Dec 23, 2017

Hmm, so, this lib is the best at what it does (sublime's search), but that's all it does.
You're probably better off using a different lib.

But if you want to hack this, the only issue seems to be that you want to check for misspellings.
Which you could do by looping through all permutations of their search, this lib should be fast enough to deal with that.

Maybe give me the list of all coins, and some example searches with what you expect and why, then i'll give you a hacked permutation search wrapper (if it's possible)

@slidenerd
Copy link
Author

This would be the list of coins https://api.coinmarketcap.com/v1/ticker/?convert=EUR&limit=0 let me know if I can help in any way Thanks

@farzher
Copy link
Owner

farzher commented Dec 23, 2017

Try this, let me know what's wrong with it. coins is the array of objects you showed me, i'm using rank for better sorting.

function coinsearch(search, coins) {
  var results = fuzzysort.go(search, coins, {key:'symbol'})

  var letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
  for (var i = 0; i < search.length; i++) {
    for (var j = 0; j < letters.length; j++) {
      var tmp_s = search.substr(0, i) + letters[j] + search.substr(i+1)
      var tmp_results = fuzzysort.go(tmp_s, coins, {key:'symbol'})
      if(tmp_results.length === 0) continue
      var tmp_result = tmp_results[0]
      tmp_result.score -= tmp_result.obj.rank // penalty for being a less popular coin
      results.push(tmp_result)
    }
  }

  return results.sort(function(a, b) { return b.score - a.score })
}
console.log(coinsearch('etx', coins)[0])
// console.log(coinsearch('BTR', coins)[0])

@slidenerd
Copy link
Author

Hey thanks for the superfast response, I tested the code snippet it worked very well with ETX, I tried BTR and it gives the following results. Since BTC is the nearest one off by one character, I think it should be popping that up, Perhaps levenshtein s distance between the current symbol BTR and any symbol that has atleast one character in common with BTR will yield an array where the lowest score would give BTC

[ { score: -3001,
    target: 'BTSR',
    indexes: [ 0, 1, 3 ],
    obj:
     { id: 'btsr',
       name: 'BTSR',
       symbol: 'BTSR',
       rank: '846',
       price_usd: '0.270346',
       price_btc: '0.00001853',
       '24h_volume_usd': '47.4174',
       market_cap_usd: '887888.0',
       available_supply: '3284266.0',
       total_supply: '3284266.0',
       max_supply: null,
       percent_change_1h: '0.67',
       percent_change_24h: '-12.48',
       percent_change_7d: '30.49',
       last_updated: '1513916953',
       price_eur: '0.2278232777',
       '24h_volume_eur': '39.959117154',
       market_cap_eur: '748232.0' } },
  { score: -3001,
    target: 'BTCR',
    indexes: [ 0, 1, 3 ],
    obj:
     { id: 'bitcurrency',
       name: 'Bitcurrency',
       symbol: 'BTCR',
       rank: '868',
       price_usd: '0.00262619',
       price_btc: '0.00000018',
       '24h_volume_usd': '375.814',
       market_cap_usd: '445398.0',
       available_supply: '169598616.0',
       total_supply: '169598616.0',
       max_supply: null,
       percent_change_1h: '5.68',
       percent_change_24h: '-29.08',
       percent_change_7d: '-40.49',
       last_updated: '1513916958',
       price_eur: '0.0022131166',
       '24h_volume_eur': '316.70221594',
       market_cap_eur: '375342.0' } },
  { score: -3003,
    target: 'BTCRED',
    indexes: [ 0, 1, 3 ],
    obj:
     { id: 'bitcoin-red',
       name: 'Bitcoin Red',
       symbol: 'BTCRED',
       rank: '489',
       price_usd: '0.151597',
       price_btc: '0.00001039',
       '24h_volume_usd': '165202.0',
       market_cap_usd: '2747684.0',
       available_supply: '18124926.0',
       total_supply: '21000000.0',
       max_supply: null,
       percent_change_1h: '-7.32',
       percent_change_24h: '12.04',
       percent_change_7d: '-38.75',
       last_updated: '1513916977',
       price_eur: '0.1277523079',
       '24h_volume_eur': '139217.37742',
       market_cap_eur: '2315501.0' } },
  { score: -3021,
    target: 'BRIT',
    indexes: [ 0, 1, 3 ],
    obj:
     { id: 'britcoin',
       name: 'BritCoin',
       symbol: 'BRIT',
       rank: '498',
       price_usd: '0.118994',
       price_btc: '0.00000816',
       '24h_volume_usd': '2306.96',
       market_cap_usd: '2530775.0',
       available_supply: '21268092.0',
       total_supply: '21268092.0',
       max_supply: null,
       percent_change_1h: '-4.01',
       percent_change_24h: '13.58',
       percent_change_7d: '9.34',
       last_updated: '1513916945',
       price_eur: '0.1002774337',
       '24h_volume_eur': '1944.0982616',
       market_cap_eur: '2132710.0' } },
  { score: -3021,
    target: 'BRAT',
    indexes: [ 0, 1, 3 ],
    obj:
     { id: 'brat',
       name: 'BROTHER',
       symbol: 'BRAT',
       rank: '785',
       price_usd: '0.000574633',
       price_btc: '0.00000004',
       '24h_volume_usd': '901.446',
       market_cap_usd: '91941.0',
       available_supply: '160000000.0',
       total_supply: '1000000000.0',
       max_supply: null,
       percent_change_1h: '6.39',
       percent_change_24h: '11.51',
       percent_change_7d: '57.38',
       last_updated: '1513916972',
       price_eur: '0.000484249',
       '24h_volume_eur': '759.65755866',
       market_cap_eur: '77480.0' } },
  { score: -6002,
    target: 'BSTAR',
    indexes: [ 0, 2, 4 ],
    obj:
     { id: 'blackstar',
       name: 'Blackstar',
       symbol: 'BSTAR',
       rank: '943',
       price_usd: '0.000145899',
       price_btc: '0.00000001',
       '24h_volume_usd': '1.45899',
       market_cap_usd: '92033.0',
       available_supply: '630795971.0',
       total_supply: '630795971.0',
       max_supply: null,
       percent_change_1h: '5.62',
       percent_change_24h: null,
       percent_change_7d: null,
       last_updated: '1513916958',
       price_eur: '0.0001229505',
       '24h_volume_eur': '1.2295054629',
       market_cap_eur: '77557.0' } },
  { score: -6022,
    target: 'BURST',
    indexes: [ 0, 2, 4 ],
    obj:
     { id: 'burst',
       name: 'Burst',
       symbol: 'BURST',
       rank: '155',
       price_usd: '0.0352389',
       price_btc: '0.00000242',
       '24h_volume_usd': '9355430.0',
       market_cap_usd: '63441995.0',
       available_supply: '1800339818.0',
       total_supply: '1800339818.0',
       max_supply: '2158812800.0',
       percent_change_1h: '9.13',
       percent_change_24h: '-2.31',
       percent_change_7d: '108.81',
       last_updated: '1513916945',
       price_eur: '0.0296961734',
       '24h_volume_eur': '7883914.4153',
       market_cap_eur: '53463203.0' } },
  { score: -7003,
    target: 'BITEUR',
    indexes: [ 0, 2, 5 ],
    obj:
     { id: 'biteur',
       name: 'bitEUR',
       symbol: 'BITEUR',
       rank: '763',
       price_usd: '1.24099',
       price_btc: '0.00008506',
       '24h_volume_usd': '7185.83',
       market_cap_usd: '142381.0',
       available_supply: '114732.0',
       total_supply: '114732.0',
       max_supply: null,
       percent_change_1h: '7.2',
       percent_change_24h: '-0.19',
       percent_change_7d: '-8.57',
       last_updated: '1513916963',
       price_eur: '1.0457946829',
       '24h_volume_eur': '6055.5707993',
       market_cap_eur: '119986.0' } },
  { score: -10006,
    target: 'BITSILVER',
    indexes: [ 0, 2, 8 ],
    obj:
     { id: 'bitsilver',
       name: 'bitSilver',
       symbol: 'BITSILVER',
       rank: '700',
       price_usd: '18.7966',
       price_btc: '0.00128832',
       '24h_volume_usd': '17002.3',
       market_cap_usd: '342341.0',
       available_supply: '18213.0',
       total_supply: '18213.0',
       max_supply: null,
       percent_change_1h: '0.05',
       percent_change_24h: '-2.89',
       percent_change_7d: '-6.13',
       last_updated: '1513916956',
       price_eur: '15.840082786',
       '24h_volume_eur': '14328.008233',
       market_cap_eur: '288494.0' } },
  total: 9 ]

@farzher
Copy link
Owner

farzher commented Dec 24, 2017

oops. i edited the coinsearch function, try the new one.

@slidenerd
Copy link
Author

Awesome man! it freaking works!!! This is so badass, thank you man, headed back to stackoverflow to modify my comment, Merry Xmas

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants