Created
February 4, 2019 17:28
-
-
Save richie3366/41c8f785d19a0513b3aa3774b61981ab to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let langStats = {} | |
data.forEach(e => { | |
langStats[e.tweet_lang] = (langStats[e.tweet_lang] || 0) + 1 | |
}) | |
console.log(Object.entries(langStats).sort(([langA, countA], [langB, countB]) => countA < countB ? 1 : -1) | |
.slice(0, 10).map(([lang, count]) => `${lang} ${Math.floor((count / data.length) * 100)}%`)) | |
/* | |
Outputs: | |
[ 'en 29%', | |
'th 27%', | |
'ja 24%', | |
'ar 6%', | |
'ko 2%', | |
'es 2%', | |
'in 1%', | |
'und 1%', | |
'tr 1%', | |
'fr 0%' ] | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment