def build_tree(self, filepath): freqs = kdprims.calc_char_freqs(filepath) pq = btl.init_queue(freqs) while len(pq) > 1: n1 = pq.pop() n2 = pq.pop() pq.insert(btl.Node(n1, n2)) self.tree = pq[0]
def build_tree(self, filepath): freqs = kdprims.calc_char_freqs(filepath) pq = btl.init_queue(freqs) while len(pq) > 1: n1 = pq.pop() n2 = pq.pop() pq.insert(btl.Node(n1,n2)) self.tree = pq[0]
def gen_freqs(self, filepath='corpus1.txt'): self.freqs = kd.calc_char_freqs(filepath)
def __init__(self): filepath = './corpus1.txt' freqs = kdprims.calc_char_freqs(filepath) self.__build_tree(freqs)
def __init__(self): super().__init__() self.corpus = "/Users/Tsh/workspace/ntnu/Plab2/exercise3/corpus1.txt" self.build_tree(kdprims.calc_char_freqs(self.corpus, lc=True))