def generate_edit_distance(tree, idf=False): keys = tree.keys() keys = map(int, keys) keys.sort() for k in keys: k = str(k) hypothesis = tree[k]["hypothesis"] text = tree[k]["text"] if idf: d = distance(text, hypothesis, costs=idf_cost) else: d = distance(text,hypothesis) yield k, d, hypothesis, text
def hypothesis_to_none_ted(hypothesis, idf_enabled=False): if idf_enabled: d = distance(Node("E", "join", ""), hypothesis, costs=idf_cost) else: d = distance(Node("E", "join", ""), hypothesis) return d