File size: 1,097 Bytes
c5f913a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9d648a5
c5f913a
 
 
 
 
 
 
 
 
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
import random
from src.metrics import get_word_list


class Cerebrum:
    def __init__(self,vowel_knowledge:int=2) -> None:
        self.word_list = get_word_list()
        self.init_word_list = self.get_vowelled_word_list(vowel_knowledge)
    
    def get_vowelled_word_list(self,nos_vowels:int)->list:
        """
        Returns a list of words with the given number of vowels.
        """
        vowels = set(["a","e","i","o","u"])
        tmp_list = []
        for word in self.word_list:
            ind_word_set = set(list(word))
            if len(list(vowels.intersection(ind_word_set))) > nos_vowels:
                tmp_list.append(word)
        return tmp_list

    def random_first_choice(self)->str:
        return random.choice(self.init_word_list)

    def random_n_choice(self,hash_output)->str:
        if len(hash_output) == 1:
            return random.choice(hash_output[0])
        else:
            sub_hash = random.choice(hash_output)
            return random.choice(sub_hash)

if __name__ == "__main__":
    cerebrum = Cerebrum()
    print(len(cerebrum.init_word_list))