Ejemplo n.º 1
0
def main():
    t = Trie.TrieNode()         # Create the root node
    t.build()
    os.system("cls")
    print("This is the extra-credit.")
    while len(Trie.randomWord) < 1:
        t.randomLookUp()
    randword = random.choice(Trie.randomWord)
    print()
    t.printRandomBetter(randword)
Ejemplo n.º 2
0
 def load_data():
     with open('csv_data/data.csv', 'r') as f:
         reader = csv.reader(f, delimiter=',')
         headers = next(reader)
         data = list(reader)
     trie = Trie.TrieNode()
     for elem in data:
         if ' ' in elem: elem.remove(' ')
         if '' in elem: elem.remove('')
         trie.insert(' '.join(elem).strip().lower())
     return trie
Ejemplo n.º 3
0
def main():
    t = Trie.TrieNode()  # Create the root node
    t.build()

    while len(Trie.randomWord) < 100:
        t.randomLookUp()
    os.system("cls")
    print(
        "This is Part 1: 100 random words from Alice in Wonderland, please notice that there are no repeat words.\n"
    )
    t.printRandom()
    print("\n\n")
Ejemplo n.º 4
0
def build_trie(word_dict):
    root = Trie.TrieNode()
    for vocab in word_dict:
        root.insert(vocab)
    print 'Finish building Trie.'
    return root