From b3c6da59b82893ce953b1789ea7b0da8b3a39706 Mon Sep 17 00:00:00 2001 From: Michiel Scholten Date: Tue, 19 Nov 2024 15:20:20 +0100 Subject: [PATCH] Only use Scrabble words when available --- wordlist/create_list.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/wordlist/create_list.py b/wordlist/create_list.py index 07ffa2e..2bbdc47 100644 --- a/wordlist/create_list.py +++ b/wordlist/create_list.py @@ -1,3 +1,4 @@ +import os.path import random MIN_LENGTH = 4 @@ -12,9 +13,13 @@ with open('wikiwoordenboek_basiswoorden.lst', 'r', encoding='utf-8') as wordfile wikiwoorden_words = wordfile.readlines() print(f'wikiwoorden basic list contains {len(wikiwoorden_words)} words') -with open('scrabblewoorden.txt', 'r', encoding='utf-8') as wordfile: - scrabble_words = wordfile.readlines() - print(f'scrabblewoorden list contains {len(scrabble_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: basis_words = wordfile.readlines()