def read_elp(self): self.tree = PrefixTree() self.pronunciations = {} words = list(csv.DictReader(open(paths.elp))) for i, x in enumerate(words): pron = self.elp2cmu.translate(x['Pron']) if x[self.frequency_field] not in ['0', 'NULL']: self.tree.insert(tuple(pron + ['#']), float(x[self.frequency_field]), x['Word']) self.pronunciations[x['Word']] = pron self.tree.calculate_probs()