Skip to content

Instantly share code, notes, and snippets.

@Hugo-ter-Doest
Created January 14, 2019 09:22
Show Gist options
  • Save Hugo-ter-Doest/ee9034993c0e97c9ec332313741e9d4e to your computer and use it in GitHub Desktop.
Save Hugo-ter-Doest/ee9034993c0e97c9ec332313741e9d4e to your computer and use it in GitHub Desktop.
Convert Snowball file
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