From 8c719d6edfeb7442f8dce8a90393baf403635db8 Mon Sep 17 00:00:00 2001 From: amlarraz Date: Thu, 17 Jun 2021 11:01:32 +0200 Subject: [PATCH] Fixed the spurious count Fixed the spurious to make it according with the note in line 310. If the spurious detection label is in the label-set, +1 in the spurious count for this label, else +1 in the spurious count of all labels --- ner_evaluation/ner_eval.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/ner_evaluation/ner_eval.py b/ner_evaluation/ner_eval.py index afae462..31ba1c6 100644 --- a/ner_evaluation/ner_eval.py +++ b/ner_evaluation/ner_eval.py @@ -313,13 +313,18 @@ def compute_metrics(true_named_entities, pred_named_entities, tags): # level. In this case, it is applied to all target_tags # found in this example. This will mean that the sum of the # evaluation_agg_entities will not equal evaluation. - - for true in tags: - - evaluation_agg_entities_type[true]['strict']['spurious'] += 1 - evaluation_agg_entities_type[true]['ent_type']['spurious'] += 1 - evaluation_agg_entities_type[true]['partial']['spurious'] += 1 - evaluation_agg_entities_type[true]['exact']['spurious'] += 1 + + if pred.e_type not in tags: + for true in tags: + evaluation_agg_entities_type[true]['strict']['spurious'] += 1 + evaluation_agg_entities_type[true]['ent_type']['spurious'] += 1 + evaluation_agg_entities_type[true]['partial']['spurious'] += 1 + evaluation_agg_entities_type[true]['exact']['spurious'] += 1 + else: + evaluation_agg_entities_type[pred.e_type]['strict']['spurious'] += 1 + evaluation_agg_entities_type[pred.e_type]['ent_type']['spurious'] += 1 + evaluation_agg_entities_type[pred.e_type]['partial']['spurious'] += 1 + evaluation_agg_entities_type[pred.e_type]['exact']['spurious'] += 1 # Scenario III: Entity was missed entirely.