Comments (13)
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.
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] + ": ");
from crypto-symbol.
from crypto-symbol.
can you tell me
what is your input?
what is your expected output?
from crypto-symbol.
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.
expected output: only the symbols withput those with only 1,2 char...
from crypto-symbol.
currently using this to get the tickers , since using the getsymbol function doesnt work when trying to get multiple symbols.
from crypto-symbol.
can you post the raw text for this one?
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.
[
' 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.
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);
from crypto-symbol.
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.
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);
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.
partially solved by using regex expression
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from crypto-symbol.