in modeling/coval/eval/evaluator.py [0:0]
def lea(input_clusters, output_clusters, mention_to_gold):
num, den = 0, 0
for c in input_clusters:
if len(c) == 1:
all_links = 1
if c[0] in mention_to_gold and len(
output_clusters[mention_to_gold[c[0]]]) == 1:
common_links = 1
else:
common_links = 0
else:
common_links = 0
all_links = len(c) * (len(c) - 1) / 2.0
for i, m in enumerate(c):
if m in mention_to_gold:
for m2 in c[i + 1:]:
if m2 in mention_to_gold and mention_to_gold[
m] == mention_to_gold[m2]:
common_links += 1
# else:
# print('!! ', m2, '--', m2.get_span(), ' ',
# m2.min_spans, ' ', mention_to_gold[m], ' ',
# mention_to_gold[m2], ' ' ,
# [str(s) for s in output_clusters[
# mention_to_gold[m]]], ' -- ',
# [str(s) for s in output_clusters[
# mention_to_gold[m2]]])
num += len(c) * common_links / float(all_links)
den += len(c)
return num, den