Giter Site home page Giter Site logo

Comments (13)

Diogovski avatar Diogovski commented on May 28, 2024

If i use the .includes() function while looping for the object of the tickers i am able to get this
'BTC,ETH,BNB,XRP,ADA,SOL,DOGE,DOT,MATIC,SHIB,T,HI,OG,SHI,D,TH,MAT,A,IC,G,O,DOG,BT'
it returns all the one i need/want, but unfortunately it alsos breaks them appart

from crypto-symbol.

tylim88 avatar tylim88 commented on May 28, 2024

you mean nameLookup?

not possible to transform multiple ticker in one string, but for your case you can do some parsing

import { cryptoSymbol } from "crypto-symbol";

const { nameLookup } = cryptoSymbol({});

const longString =
  "Price analysis 9/14: BTC, ETH, BNB, XRP, ADA, SOL, DOGE, DOT, MATIC, SHIB";

const splitted = longString.split(":");

const tickersArr = splitted[1].split(",");

const getNames = tickersArr.reduce((acc, item, index) => {
  return acc + nameLookup(item) + (index === tickersArr.length - 1 ? "" : ", ");
}, splitted[0] + ": "); 

image

from crypto-symbol.

Diogovski avatar Diogovski commented on May 28, 2024

from crypto-symbol.

tylim88 avatar tylim88 commented on May 28, 2024

can you tell me
what is your input?
what is your expected output?

from crypto-symbol.

Diogovski avatar Diogovski commented on May 28, 2024

my input is different phrases, some only have bitcoin on it, others have other coins on it,
the expected output is the symbols of the coins mentioned on each phrase

from crypto-symbol.

Diogovski avatar Diogovski commented on May 28, 2024

Current input/output
image

expected output: only the symbols withput those with only 1,2 char...

from crypto-symbol.

Diogovski avatar Diogovski commented on May 28, 2024

currently using this to get the tickers , since using the getsymbol function doesnt work when trying to get multiple symbols.
image

from crypto-symbol.

tylim88 avatar tylim88 commented on May 28, 2024

can you post the raw text for this one?

Current input/output image

expected output: only the symbols withput those with only 1,2 char...

I will see what I can do tomorrow, bed time now

from crypto-symbol.

Diogovski avatar Diogovski commented on May 28, 2024

[
' Bitcoin exchange inflows see biggest one-day spike since March 2020 ',
' Possession of Bitcoin still legal in China despite the ban, lawyer says ',
" El Salvador's pro-Bitcoin president Nayib Bukele announces reelection bid ",
' Celsius requests permission to sell off its stablecoins ',
' Bitcoin price threatens $19.6K as Ray Dalio predicts 30% stocks crash ',
' The Ethereum Merge to proof-of-stake is complete — What’s next? | Interview with Dr. Julian Hosp ',
" Bitcoin price loses $20K, ETH price drops 8% after 'monumental' Ethereum Merge ",
' Crypto for foreign trade: What do we know about Iran’s new strategy ',
" Norwegian town wants 'noisy' Bitcoin miner out, CEO responds ",
" Michael Saylor slams 'misinformation' about Bitcoin’s energy use ",
' Price analysis 9/14: BTC, ETH, BNB, XRP, ADA, SOL, DOGE, DOT, MATIC, SHIB ',
" Analyst on $17.6K BTC price bottom: Bitcoin 'not there yet' ",
' BTC price clings to $20K as US stocks lose the equivalent of 4 Bitcoin market caps ',
' Bitcoin is the perfect settlement layer to build apps on top of: Hiro CEO ',
' Bitcoin margin long-to-short ratio at Bitfinex reaches the highest level ever '
]
[
'BTC',
'BTC',
'BTC',
'CEL',
'BTC,D,DALI',
'ETH,T,D',
'BTC,ETH,T,TH',
'',
'BTC,O',
'BTC',
'BTC,ETH,BNB,XRP,ADA,SOL,DOGE,DOT,MATIC,SHIB,T,HI,OG,SHI,D,TH,MAT,A,IC,G,O,DOG,BT',
'BTC,T,A,BT',
'BTC,T,U,BT',
'BTC,O',
'BTC'
]

from crypto-symbol.

tylim88 avatar tylim88 commented on May 28, 2024
import { cryptoSymbol } from "crypto-symbol";

const { symbolLookup, nameLookup } = cryptoSymbol({});

const titleArr = [
  " Bitcoin exchange inflows see biggest one-day spike since March 2020 ",
  " Possession of Bitcoin still legal in China despite the ban, lawyer says ",
  " El Salvador's pro-Bitcoin president Nayib Bukele announces reelection bid ",
  " Celsius requests permission to sell off its stablecoins ",
  " Bitcoin price threatens $19.6K as Ray Dalio predicts 30% stocks crash ",
  " The Ethereum Merge to proof-of-stake is complete — What’s next? | Interview with Dr. Julian Hosp ",
  " Bitcoin price loses $20K, ETH price drops 8% after 'monumental' Ethereum Merge ",
  " Crypto for foreign trade: What do we know about Iran’s new strategy ",
  " Norwegian town wants 'noisy' Bitcoin miner out, CEO responds ",
  " Michael Saylor slams 'misinformation' about Bitcoin’s energy use ",
  " Price analysis 9/14: BTC, ETH, BNB, XRP, ADA, SOL, DOGE, DOT, MATIC, SHIB ",
  " Analyst on $17.6K BTC price bottom: Bitcoin 'not there yet' ",
  " BTC price clings to $20K as US stocks lose the equivalent of 4 Bitcoin market caps ",
  " Bitcoin is the perfect settlement layer to build apps on top of: Hiro CEO ",
  " Bitcoin margin long-to-short ratio at Bitfinex reaches the highest level ever "
];

const answ = titleArr.map((title) => {
  const arr: string[] = [];
  title.split(" ").forEach((word) => {
    const found =
      symbolLookup(word) ||
      symbolLookup(nameLookup(word) || "hsuadhiudhsudhahdi");
    found && arr.push(found);
  });
  return arr;
});
console.log(answ);

image

from crypto-symbol.

Diogovski avatar Diogovski commented on May 28, 2024

thx, its looking better now, i added something so it removes duplicates from the arrays ( mainly BTC ), now gonna try to figure out how to remove those that aren't actually referred as symbols but words

from crypto-symbol.

tylim88 avatar tylim88 commented on May 28, 2024

some coin symbol are English word, you can add a list to filter it out

import { cryptoSymbol } from "crypto-symbol";

const { symbolLookup, nameLookup } = cryptoSymbol({});

const titleArr = [
  " Bitcoin exchange inflows see biggest one-day spike since March 2020 ",
  " Possession of Bitcoin still legal in China despite the ban, lawyer says ",
  " El Salvador's pro-Bitcoin president Nayib Bukele announces reelection bid ",
  " Celsius requests permission to sell off its stablecoins ",
  " Bitcoin price threatens $19.6K as Ray Dalio predicts 30% stocks crash ",
  " The Ethereum Merge to proof-of-stake is complete — What’s next? | Interview with Dr. Julian Hosp ",
  " Bitcoin price loses $20K, ETH price drops 8% after 'monumental' Ethereum Merge ",
  " Crypto for foreign trade: What do we know about Iran’s new strategy ",
  " Norwegian town wants 'noisy' Bitcoin miner out, CEO responds ",
  " Michael Saylor slams 'misinformation' about Bitcoin’s energy use ",
  " Price analysis 9/14: BTC, ETH, BNB, XRP, ADA, SOL, DOGE, DOT, MATIC, SHIB ",
  " Analyst on $17.6K BTC price bottom: Bitcoin 'not there yet' ",
  " BTC price clings to $20K as US stocks lose the equivalent of 4 Bitcoin market caps ",
  " Bitcoin is the perfect settlement layer to build apps on top of: Hiro CEO ",
  " Bitcoin margin long-to-short ratio at Bitfinex reaches the highest level ever "
];

const englishWords = ["layer", "ever", "build", "top", "caps"];

const answ = titleArr.map((title) => {
  const arr: string[] = [];
  const exist: Record<string, boolean> = {};
  title.split(" ").forEach((word) => {
    const isEnglishWord = englishWords.some((eword) => {
      return word.toLowerCase().includes(eword);
    });
    if (!isEnglishWord) {
      const found =
        symbolLookup(word) ||
        symbolLookup(nameLookup(word) || "hsuadhiudhsudhahdi");

      const isDuplicated = exist[`${found}`];
      exist[`${found}`] = true;
      !isDuplicated && found && arr.push(found);
    }
  });
  return arr;
});

console.log(answ);

image

there is problem with matching text like bitcoin's, because this is a lookup library, it can filter out unnecessary character but it cant match the closest text

example:
bitcoin' --> bitcoin --> found!
bitcoin's --> bitcoins --> not found!

from crypto-symbol.

tylim88 avatar tylim88 commented on May 28, 2024

partially solved by using regex expression

image

import { cryptoSymbol } from "crypto-symbol";

const { symbolLookup, nameLookup } = cryptoSymbol({});

const titleArr = [
  " Bitcoin exchange inflows see biggest one-day spike since March 2020 ",
  " Possession of Bitcoin still legal in China despite the ban, lawyer says ",
  " El Salvador's pro-Bitcoin president Nayib Bukele announces reelection bid ",
  " Celsius requests permission to sell off its stablecoins ",
  " Bitcoin price threatens $19.6K as Ray Dalio predicts 30% stocks crash ",
  " The Ethereum Merge to proof-of-stake is complete — What’s next? | Interview with Dr. Julian Hosp ",
  " Bitcoin price loses $20K, ETH price drops 8% after 'monumental' Ethereum Merge ",
  " Crypto for foreign trade: What do we know about Iran’s new strategy ",
  " Norwegian town wants 'noisy' Bitcoin miner out, CEO responds ",
  " Michael Saylor slams 'misinformation' about Bitcoin’s energy use ",
  " Price analysis 9/14: BTC, ETH, BNB, XRP, ADA, SOL, DOGE, DOT, MATIC, SHIB ",
  " Analyst on $17.6K BTC price bottom: Bitcoin 'not there yet' ",
  " BTC price clings to $20K as US stocks lose the equivalent of 4 Bitcoin market caps ",
  " Bitcoin is the perfect settlement layer to build apps on top of: Hiro CEO ",
  " Bitcoin margin long-to-short ratio at Bitfinex reaches the highest level ever "
];

const englishWords = ["layer", "ever", "build", "top", "caps"];

const answ = titleArr.map((title) => {
  const arr: string[] = [];
  const exist: Record<string, boolean> = {};
  title.split(/[,.’'\s]/).forEach((word) => {
    const isEnglishWord = englishWords.some((eword) => {
      return word.toLowerCase().includes(eword);
    });
    if (!isEnglishWord) {
      const found =
        symbolLookup(word) ||
        symbolLookup(nameLookup(word) || "hsuadhiudhsudhahdi");

      const isDuplicated = exist[`${found}`];
      exist[`${found}`] = true;
      !isDuplicated && found && arr.push(found);
    }
  });
  return arr;
});

now it is able to match bitcoin's but still not able to match bitcoins, I will put this on roadmap

from crypto-symbol.

Related Issues (3)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.