Improved dictionary.

This commit is contained in:
ThePendulum 2024-06-09 18:07:52 +02:00
parent f384d595e4
commit ab25066936
5 changed files with 369549 additions and 102257 deletions

190169
assets/dictionary.json Executable file → Normal file

File diff suppressed because one or more lines are too long

102260
assets/dictionary_old.json Executable file

File diff suppressed because one or more lines are too long

89675
assets/words Normal file

File diff suppressed because it is too large Load Diff

View File

@ -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();

89677
assets/words.json Normal file

File diff suppressed because it is too large Load Diff