more words2
This commit is contained in:
@@ -1,5 +1,18 @@
|
||||
import fs from 'node:fs';
|
||||
import wordlistEnglish from 'wordlist-english';
|
||||
|
||||
const COMBO_WORDS_FILE = new URL('./combo-words.txt', import.meta.url);
|
||||
|
||||
// Extra words (from scripts/find-missing-combo-words.mjs) that are buildable
|
||||
// from pool tiles but missing from wordlist-english. Accepted in play only.
|
||||
export function loadComboWords() {
|
||||
if (!fs.existsSync(COMBO_WORDS_FILE)) return [];
|
||||
return fs.readFileSync(COMBO_WORDS_FILE, 'utf8')
|
||||
.split(/\r?\n/)
|
||||
.map(l => l.trim().toLowerCase())
|
||||
.filter(l => l && !l.startsWith('#') && /^[a-z]+$/.test(l));
|
||||
}
|
||||
|
||||
// Shared dictionary sources for the client lexicon and the build-time solver.
|
||||
|
||||
// Valid 2-letter English words accepted in standard games
|
||||
@@ -40,7 +53,7 @@ function isAcceptable(w) {
|
||||
return w.length >= 3 && w.length <= 16 && /^[a-z]+$/.test(w);
|
||||
}
|
||||
|
||||
export function buildWordSet() {
|
||||
export function buildWordSet({ includeComboWords = false } = {}) {
|
||||
const set = new Set();
|
||||
for (const key of SOURCE_LISTS) {
|
||||
for (const raw of wordlistEnglish[key] || []) {
|
||||
@@ -51,6 +64,11 @@ export function buildWordSet() {
|
||||
for (const w of PROPER_WORD_ALLOWLIST) {
|
||||
if (isAcceptable(w)) set.add(w);
|
||||
}
|
||||
if (includeComboWords) {
|
||||
for (const w of loadComboWords()) {
|
||||
if (isAcceptable(w)) set.add(w);
|
||||
}
|
||||
}
|
||||
return set;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user