more words2
This commit is contained in:
@@ -1,11 +1,15 @@
|
||||
import fs from 'node:fs';
|
||||
import { buildWordSet } from './lexicon-sources.mjs';
|
||||
import { buildWordSet, loadComboWords } from './lexicon-sources.mjs';
|
||||
|
||||
// Build a clean, high-frequency recognized vocabulary for client-side unlimited/custom puzzles
|
||||
// (includes regional spellings and the proper-word allowlist)
|
||||
const vocabulary = buildWordSet();
|
||||
|
||||
// Accept-only words (scripts/combo-words.txt): valid in play, never shown in solution lists
|
||||
const comboWords = [...new Set(loadComboWords())].filter(w => !vocabulary.has(w)).sort();
|
||||
|
||||
console.log('Total vocabulary words:', vocabulary.size);
|
||||
console.log('Accept-only combo words:', comboWords.length);
|
||||
|
||||
// Pack into space-separated string or array
|
||||
const sortedWords = [...vocabulary].sort();
|
||||
@@ -15,6 +19,11 @@ const RAW_LEXICON = ${JSON.stringify(sortedWords)};
|
||||
|
||||
export const DICTIONARY_SET = new Set(RAW_LEXICON);
|
||||
|
||||
// Accept-only words buildable from pool tiles (generated by
|
||||
// scripts/find-missing-combo-words.mjs). Space-packed to keep the bundle small.
|
||||
const RAW_COMBO_WORDS = ${JSON.stringify(comboWords.join(' '))};
|
||||
export const COMBO_WORD_SET = new Set(RAW_COMBO_WORDS ? RAW_COMBO_WORDS.split(' ') : []);
|
||||
|
||||
// Prefix set for lightning fast tree-pruning search (1 to 6 chars)
|
||||
export const PREFIX_SET = new Set();
|
||||
for (const word of RAW_LEXICON) {
|
||||
@@ -26,6 +35,12 @@ for (const word of RAW_LEXICON) {
|
||||
export function isWordValid(word) {
|
||||
return DICTIONARY_SET.has(word.toLowerCase());
|
||||
}
|
||||
|
||||
// Any word a player may submit: main dictionary + accept-only combo words
|
||||
export function isAcceptedWord(word) {
|
||||
const w = word.toLowerCase();
|
||||
return DICTIONARY_SET.has(w) || COMBO_WORD_SET.has(w);
|
||||
}
|
||||
`;
|
||||
|
||||
fs.writeFileSync('src/data/lexicon.js', lexiconContent, 'utf8');
|
||||
|
||||
Reference in New Issue
Block a user