Improved dictionary.
This commit is contained in:
parent
f384d595e4
commit
ab25066936
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,25 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const fs = require('fs').promises;
|
||||||
|
|
||||||
|
const words = require('./words.json');
|
||||||
|
const dictionary = require('./dictionary_old.json');
|
||||||
|
|
||||||
|
async function init() {
|
||||||
|
const definitions = Object.fromEntries(words.map((word) => {
|
||||||
|
const normalizedWord = word.normalize('NFD').replace(/\p{Diacritic}/ug, '').toLowerCase().trim();
|
||||||
|
const definition = dictionary[normalizedWord];
|
||||||
|
const singular = normalizedWord.replace(/s$/, '');
|
||||||
|
const singularDefinition = dictionary[singular] ? `Plural of ${singular}: ${dictionary[singular]}` : null;
|
||||||
|
|
||||||
|
return [normalizedWord, definition || singularDefinition];
|
||||||
|
}));
|
||||||
|
|
||||||
|
const string = JSON.stringify(definitions, null, 4);
|
||||||
|
|
||||||
|
await fs.writeFile('./dictionary.json', string);
|
||||||
|
|
||||||
|
console.log(`Wrote ${Object.keys(definitions).length} words to ./dictionary.json`);
|
||||||
|
}
|
||||||
|
|
||||||
|
init();
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue