Created
January 14, 2019 09:22
-
-
Save Hugo-ter-Doest/ee9034993c0e97c9ec332313741e9d4e to your computer and use it in GitHub Desktop.
Convert Snowball file
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
var fs = require('fs'); | |
var inputFile = './spec/test_data/snowball_fr.txt'; | |
var outputFile = './spec/test_data/snowball_fr.json'; | |
var data = fs.readFileSync(inputFile, 'utf8'); | |
var lines = data.split(/[\n\r]+/); | |
var dict = {}; | |
lines.forEach(line => { | |
[word, stem] = line.split(/\s+/); | |
console.log(word + ": " + stem); | |
dict[word] = stem; | |
}); | |
fs.writeFileSync(outputFile, JSON.stringify(dict, null, 2)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment