Created
March 22, 2019 13:58
-
-
Save wcandillon/636bf8631d42b004ba3ba55dcefbeef0 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
const fs = require("fs"); | |
const languages = ["de", "it", "fr", "es", "en", "pt", "zh_Hant", "ko", "ja"]; | |
const results = languages.map(lang => { | |
const result = {}; | |
const txt = fs.readFileSync(`./synonyms/cldr-emoji-annotation-synonyms-${lang}.txt`, { encoding: "UTF-8"}); | |
txt.split("\n") | |
.map(line => line.split("=>").map(token => token.trim())) | |
.filter(([emoji, metadata]) => metadata !== undefined) | |
.forEach(([emoji, metadata]) => { | |
result[emoji] = metadata.split(",")[1].trim(); | |
}); | |
return result; | |
}); | |
const result = {}; | |
Object.keys(results[0]).forEach((emoji) => { | |
result[emoji] = {}; | |
results.forEach((r, i) => { | |
const lang = languages[i]; | |
result[emoji][lang] = r[emoji]; | |
}); | |
}); | |
console.log(JSON.stringify(result, null, 2)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment