many many fixes
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import fs from 'node:fs';
|
||||
import { buildWordSet, loadComboWords } from './lexicon-sources.mjs';
|
||||
import { buildWordSet, loadComboWords, getCommonnessScore } 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)
|
||||
@@ -13,12 +13,26 @@ console.log('Accept-only combo words:', comboWords.length);
|
||||
|
||||
// Pack into space-separated string or array
|
||||
const sortedWords = [...vocabulary].sort();
|
||||
// One digit (0-4) per word, parallel to RAW_LEXICON. Compresses to almost nothing.
|
||||
const commonnessDigits = sortedWords.map(w => getCommonnessScore(w)).join('');
|
||||
const lexiconContent = `// Client-side recognized English words for solver & custom puzzles
|
||||
// Loaded as a Set for O(1) instantaneous lookup
|
||||
const RAW_LEXICON = ${JSON.stringify(sortedWords)};
|
||||
|
||||
export const DICTIONARY_SET = new Set(RAW_LEXICON);
|
||||
|
||||
// Commonness tier per word (4 = most common, 0 = rare), parallel to RAW_LEXICON
|
||||
const RAW_COMMONNESS = ${JSON.stringify(commonnessDigits)};
|
||||
const COMMONNESS_MAP = new Map();
|
||||
for (let i = 0; i < RAW_LEXICON.length; i++) {
|
||||
const c = RAW_COMMONNESS.charCodeAt(i) - 48;
|
||||
if (c > 0) COMMONNESS_MAP.set(RAW_LEXICON[i], c);
|
||||
}
|
||||
|
||||
export function getCommonnessScore(word) {
|
||||
return COMMONNESS_MAP.get(word) || 0;
|
||||
}
|
||||
|
||||
// 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(' '))};
|
||||
|
||||
Reference in New Issue
Block a user