From ada1cdb14a43c96188f7e0749848459f8803039c Mon Sep 17 00:00:00 2001 From: Franck Dary <franck.dary@lis-lab.fr> Date: Fri, 30 Apr 2021 16:10:23 +0200 Subject: [PATCH] Added colnames in eval script for error comparison --- scripts/conll18_ud_eval.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scripts/conll18_ud_eval.py b/scripts/conll18_ud_eval.py index 4ddf211..8dd5ea8 100755 --- a/scripts/conll18_ud_eval.py +++ b/scripts/conll18_ud_eval.py @@ -109,6 +109,9 @@ index2col = {} metric2colname = { "UPOS" : "UPOS", "Lemmas" : "LEMMA", + "UFeats" : "FEATS", + "UAS" : "HEAD", + "LAS" : "DEPREL", } defaultColumns = { @@ -632,6 +635,9 @@ def evaluate_wrapper(args) : ################################################################################ class Error : def __init__(self, gold_file, system_file, gold_word, system_word, metric) : + if metric not in metric2colname : + raise(Exception("Metric '%s' don't have corresponding colname in '%s'"%(metric, metric2colname.keys()))) + self.gold = gold_word self.pred = system_word self.gold_sentence = gold_file.words[gold_file.sentences_words[self.gold.sentence].start:gold_file.sentences_words[self.gold.sentence].end] @@ -696,6 +702,8 @@ class ErrorType : ################################################################################ def compute_errors(gold_file, system_file, evaluation, metric) : errors = Errors(metric) + if metric not in evaluation : + raise(Exception("metric '%s' not in evaluation : '%s'"%(metric, evaluation.keys()))) for alignment_word in evaluation[metric][1] : gold = alignment_word.gold_word pred = alignment_word.system_word -- GitLab