def find_coref()

in blink/candidate_retrieval/dataset.py [0:0]


def find_coref(ment, mentlist, person_names):
    cur_m = ment["mention"].lower()
    coref = []
    for m in mentlist:
        if len(m["candidates"]) == 0 or m["candidates"][0][0] not in person_names:
            continue

        mention = m["mention"].lower()
        start_pos = mention.find(cur_m)
        if start_pos == -1 or mention == cur_m:
            continue

        end_pos = start_pos + len(cur_m) - 1
        if (start_pos == 0 or mention[start_pos - 1] == " ") and (
            end_pos == len(mention) - 1 or mention[end_pos + 1] == " "
        ):
            coref.append(m)

    return coref