3 Commits

2 changed files with 15 additions and 4 deletions

View File

@@ -36,7 +36,8 @@ document.addEventListener('alpine:init', () => {
async doGuess() { async doGuess() {
this.guessError = null; this.guessError = null;
this.guessValue = this.guessValue.toLowerCase(); /* Normalise on lowercase, and strip whitespace from begin and end, just in case */
this.guessValue = this.guessValue.toLowerCase().trim();
if (this.guessValue === '') { if (this.guessValue === '') {
console.log('Nothing filled in'); console.log('Nothing filled in');

View File

@@ -1,3 +1,4 @@
import os.path
import random import random
MIN_LENGTH = 4 MIN_LENGTH = 4
@@ -12,6 +13,14 @@ with open('wikiwoordenboek_basiswoorden.lst', 'r', encoding='utf-8') as wordfile
wikiwoorden_words = wordfile.readlines() wikiwoorden_words = wordfile.readlines()
print(f'wikiwoorden basic list contains {len(wikiwoorden_words)} words') print(f'wikiwoorden basic list contains {len(wikiwoorden_words)} words')
scrabble_words = []
if os.path.isfile('scrabblewoorden.txt'):
with open('scrabblewoorden.txt', 'r', encoding='utf-8') as wordfile:
scrabble_words = wordfile.readlines()
print(f'scrabblewoorden list contains {len(scrabble_words)} words')
else:
print('scrabblewoorden.txt not found, skipped')
with open('basiswoorden-gekeurd.txt', 'r', encoding='utf-8') as wordfile: with open('basiswoorden-gekeurd.txt', 'r', encoding='utf-8') as wordfile:
basis_words = wordfile.readlines() basis_words = wordfile.readlines()
print(f'opentaal basic list contains {len(basis_words)} words') print(f'opentaal basic list contains {len(basis_words)} words')
@@ -33,7 +42,7 @@ print()
all_words_count = 0 all_words_count = 0
dictionary_list = [] dictionary_list = []
result_list = [] result_list = []
for word in wikiwoorden_words + basis_words + flexies_words: for word in wikiwoorden_words + scrabble_words + basis_words + flexies_words:
all_words_count += 1 all_words_count += 1
word = word.strip() word = word.strip()
if word.isalpha() and word.lower() == word: if word.isalpha() and word.lower() == word:
@@ -47,7 +56,8 @@ if USE_OPENTAAL:
# Use basis_words if you want to use the big but difficult OpenTaal list # Use basis_words if you want to use the big but difficult OpenTaal list
source_words = basis_words source_words = basis_words
else: else:
source_words = wikiwoorden_words # Combine the basic words and the Scrabble word lists
source_words = wikiwoorden_words + scrabble_words
for word in source_words: for word in source_words:
word = word.strip() word = word.strip()
@@ -63,7 +73,7 @@ if USE_OPENTAAL:
filtered_set = nl_set.difference(en_set) filtered_set = nl_set.difference(en_set)
filtered_list = sorted(list(filtered_set), key=str.casefold) filtered_list = sorted(list(filtered_set), key=str.casefold)
else: else:
filtered_list = sorted(list(wikiwoorden_words), key=str.casefold) filtered_list = sorted(list(set(result_list)), key=str.casefold)
print(f'words total: {all_words_count}') print(f'words total: {all_words_count}')
print(f'words in dictionary: {len(dictionary_list)}') print(f'words in dictionary: {len(dictionary_list)}')