@staticmethod
def gen_prefix_dict(dict_f):
    """ Reads a dict file and generates the prefix dictionary with total word counts.
        """
    word_counts = {}
    with open(dict_f, 'rb') as f:
        for line in f:
            line = line.strip().decode('utf-8')
            word, freq = line.split(',')
            word_counts[word] = int(freq)
            for i in range(len(word)):
                prefix = word[:i + 1]
                if prefix not in word_counts:
                    word_counts[prefix] = 0
    return word_counts, sum(word_counts.values())
