Exemplo n.º 1
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]
Exemplo n.º 2
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]
Exemplo n.º 3
0
 def gen_freqs(self, filepath='corpus1.txt'):
     self.freqs = kd.calc_char_freqs(filepath)
Exemplo n.º 4
0
 def __init__(self):
   filepath = './corpus1.txt'
   freqs = kdprims.calc_char_freqs(filepath)
   self.__build_tree(freqs)
Exemplo n.º 5
0
 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))