Improved dictionary.
This commit is contained in:
190153
assets/dictionary.json
Executable file → Normal file
190153
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
102260
assets/dictionary_old.json
Executable file
File diff suppressed because one or more lines are too long
89675
assets/words
Normal file
89675
assets/words
Normal file
File diff suppressed because it is too large
Load Diff
25
assets/words-to-dictionary.js
Normal file
25
assets/words-to-dictionary.js
Normal 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
89677
assets/words.json
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user