Added larger mash dictionary with definitions.
This commit is contained in:
1
assets/cah-cards-full.json
Executable file
1
assets/cah-cards-full.json
Executable file
File diff suppressed because one or more lines are too long
33
assets/dictionary-to-mash.js
Normal file
33
assets/dictionary-to-mash.js
Normal file
@@ -0,0 +1,33 @@
|
||||
'use strict';
|
||||
|
||||
const fs = require('fs').promises;
|
||||
|
||||
const dictionary = require('./dictionary.json');
|
||||
|
||||
async function init() {
|
||||
const validWords = Object.entries(dictionary).filter(([word]) => /^[a-zA-Z]+$/.test(word));
|
||||
|
||||
const sortedWords = validWords.reduce((acc, [rawWord, fullDefinition]) => {
|
||||
const word = rawWord.toLowerCase();
|
||||
const anagram = word.split('').sort().join('');
|
||||
const definitions = fullDefinition.split(/\d+\.\s+/).filter(Boolean).map((definition) => definition.split('.')[0].toLowerCase());
|
||||
|
||||
if (!acc[anagram.length]) {
|
||||
acc[anagram.length] = {};
|
||||
}
|
||||
|
||||
if (!acc[anagram.length][anagram]) {
|
||||
acc[anagram.length][anagram] = [];
|
||||
}
|
||||
|
||||
acc[anagram.length][anagram].push({ word, definitions });
|
||||
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
await fs.writeFile('./mash-words.json', JSON.stringify(sortedWords, null, 4));
|
||||
|
||||
console.log(sortedWords);
|
||||
}
|
||||
|
||||
init();
|
||||
102219
assets/dictionary.json
Normal file
102219
assets/dictionary.json
Normal file
File diff suppressed because one or more lines are too long
809688
assets/mash-words.json
809688
assets/mash-words.json
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user