示例#1
0
文件: syntactic.py 项目: laat/ex3
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
示例#2
0
文件: syntactic.py 项目: laat/ex3
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