|
|
@ -7,17 +7,11 @@ def make_key(dictionary_name, letters): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def candidates(letters, dictionary: Dictionary, min=2, permutations=None): |
|
|
def candidates(letters, dictionary: Dictionary, min=2, permutations=None): |
|
|
letter_counter = Counter(letters) |
|
|
|
|
|
|
|
|
letters = "".join(letters) |
|
|
possibilities = [] |
|
|
possibilities = [] |
|
|
for word in dictionary.word_frequency.keys(): |
|
|
|
|
|
word_counter = Counter(word) |
|
|
|
|
|
try: |
|
|
|
|
|
add = all( |
|
|
|
|
|
word_counter[key] <= letter_counter[key] for key in word_counter.keys() |
|
|
|
|
|
) |
|
|
|
|
|
except KeyError: |
|
|
|
|
|
add = False |
|
|
|
|
|
if add: |
|
|
|
|
|
|
|
|
for word in filter(lambda word: len(word) > min, dictionary.word_frequency.keys()): |
|
|
|
|
|
letter_set = set(word) |
|
|
|
|
|
if all(word.count(letter) < letters.count(letter) for letter in letter_set): |
|
|
possibilities.append(word) |
|
|
possibilities.append(word) |
|
|
return possibilities |
|
|
return possibilities |
|
|
|
|
|
|
|
|
|