Example #1
0
def FillBTree():
    L = [6, 3, 16, 11, 7, 17, 14, 8, 5, 19, 15, 1, 2, 4, 18, 13, 9, 20, 10, 12, 21, 22]
    
    T = bt.BTree()    
    for i in L:
        bt.Insert(T,i)
    return T
Example #2
0
def buildBTree(max, filename):
    # set the max value of b tree to the value passed as max parameter
    T = btree.BTree([], max_data=max)
    f = open(filename, "r", encoding="utf8")
    for line in f:
        # tokenize each line into a list of strings
        tokens = line.split(" ")
        # if the value stored at the index begins with an alphabetical letter
        if tokens[0].isalpha():
            btree.Insert(T, WordEmbedding(tokens[0], tokens[1:]))

    f.close()  # close the file to save memory
    return T  # return btree
Example #3
0
def readIntoBTree(max):
    tree = btree.BTree([], max_data=max)
    with open(embed_file, encoding="utf8") as ef:
        content = ef.readline()
        #goes through every line on the file
        while content:
            word = content.split()
            #creates Word Embedding with information from file
            n = WordEmbedding.WordEmbedding(word[0], word[1:])
            #inserts on btree
            btree.Insert(tree, n)
            btree.Print
            content = ef.readline()
    print("Done")
    return tree