-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dictionary.py
83 lines (66 loc) · 2.6 KB
/
dictionary.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
'''
This file gives fully cached access to the dictionary words.
Note that dictionaries that change on disk will be reloaded automatically.
'''
from file_reader import fetch_cached_file
languages = {
'en': {
'site': 'https://www.powerlanguage.co.uk/wordle/',
'alphabet': 'qwertyuiopasdfghjklzxcvbnm',
'command': "wordy",
'help': "Guess a word in your own personal Wordy game! [English]",
},
'it': {
'site': 'https://pietroppeter.github.io/wordle-it/',
'alphabet': 'qwertyuiopasdfghjklzxcvbnm',
'command': "wordy_it",
'help': "Indovina una parola nel tuo gioco personale di Wordy! [Italiano]",
},
'fr': {
'site': 'https://wordle.louan.me/',
'alphabet': 'azertyuiopqsdfghjklmwxcvbn',
'command': "moty",
'help': "Devinez un mot dans votre propre jeu Moty personnel! [Français]",
},
'de': {
'site': 'https://wordle.uber.space/',
'alphabet': 'qwertzuiopasdfghjklyxcvbnm',
'command': "wörti",
'help': "Errate ein Wort in deinem persönlichen Wörti-Spiel! [Deutsch]",
},
'no': {
'site': 'https://evancharlton.github.io/ordle/#/nb-no',
'alphabet': 'qwertyuiopåasdfghjkløæzxcvbnm',
'command': "wørdy",
'help': "Gjett et ord i ditt personlige Wørdy spill!! [Norwegian Bokmål]",
},
'at': {
'site': 'https://wordle.at/',
'alphabet': 'qwertzuiopasdfghjklyxcvbnm',
'command': "wörti_at",
'help': "Errate ein Wort in deinem persönlichen Wörti-Spiel! [Österreichisch]",
},
}
def get_alphabet_for(lang: str) -> str:
return languages[lang]['alphabet']
def get_solution_words_for(lang: str) -> list[str]:
'''
Get the solution words for a language.
'''
if lang not in languages:
raise ValueError(f'Language {lang} is not supported')
return fetch_cached_file(f'data/{lang}/solution_words.txt', _parse_lines)
def get_acceptable_words_for(lang: str) -> list[str]:
'''
Get the acceptable guess words for a language.
'''
if lang not in languages:
raise ValueError(f'Language {lang} is not supported')
return fetch_cached_file(f'data/{lang}/accepted_words.txt', _parse_lines)
def _parse_lines(data: bytes) -> list[str]:
lines = data.decode('utf-8').splitlines()
return [word for word in lines if word]
if __name__ == '__main__':
print(len(get_solution_words_for('en')))
print(len(get_solution_words_for('en')))
print(len(get_solution_words_for('fr')))