Example #1
0
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
Example #2
0
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