Ejemplo n.º 1
0
def process_files(
    gold_fp: ty.TextIO, sys_fp: ty.TextIO, add_sys_mentions=True
) -> ty.Iterable[str]:
    gold_clusters = clusters_from_json(gold_fp)
    sys_clusters = clusters_from_json(sys_fp)
    if add_sys_mentions:
        gold_mentions: ty.Set[ty.Hashable] = set(m for c in gold_clusters for m in c)
        sys_mentions: ty.Set[ty.Hashable] = set(m for c in sys_clusters for m in c)
        extra_mentions = sys_mentions - gold_mentions
        gold_clusters.extend(set([m]) for m in extra_mentions)
    for name, metric in METRICS.items():
        R, P, F = metric(gold_clusters, sys_clusters)
        yield f"{name}:\tR={R}\tP={P}\tF₁={F}\n"
    conll_score = scores.conll2012(gold_clusters, sys_clusters)
    yield f"CoNLL-2012 average score: {conll_score}\n"
Ejemplo n.º 2
0
def test_conll2012_basic(Key, Response):
    score = scores.conll2012(Key, Response)
    assert round(score, 2) == pytest.approx(0.46)