From cd0e032647deab9a64dcaa91671cb8815b0dadcc Mon Sep 17 00:00:00 2001 From: Franck Dary <franck.dary@lis-lab.fr> Date: Thu, 18 Mar 2021 08:43:32 +0100 Subject: [PATCH] Fixed problem in conll18 eval where numeric column wasn't detected --- scripts/conll18_ud_eval.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/scripts/conll18_ud_eval.py b/scripts/conll18_ud_eval.py index ee553ac..371cbc1 100755 --- a/scripts/conll18_ud_eval.py +++ b/scripts/conll18_ud_eval.py @@ -146,10 +146,10 @@ UNIVERSAL_FEATURES = { def is_float(value) : if not isinstance(value, str) : return False - try: + try : float(value) - return '.' in value - except ValueError: + return True + except ValueError : return False ################################################################################ @@ -165,14 +165,12 @@ def filter_columns(columns) : return res ################################################################################ - ################################################################################ # UD Error is used when raising exceptions in this module class UDError(Exception) : pass ################################################################################ - ################################################################################ # Conversion methods handling `str` <-> `unicode` conversions in Python2 def _decode(text) : @@ -435,8 +433,9 @@ def evaluate(gold_ud, system_ud, extraColumns) : if filter_fn is None or filter_fn(words.gold_word) : goldItem = key_fn(words.gold_word, gold_aligned_gold) systemItem = key_fn(words.system_word, gold_aligned_system) - if (not isinstance(systemItem, str) or '.' not in systemItem or not is_float(systemItem)) or (not isinstance(goldItem, str) or '.' not in goldItem or not is_float(goldItem)) : + if (not is_float(systemItem)) or (not is_float(goldItem)) : isNumericOnly = False + break correct = [0,0] errors = [] @@ -451,8 +450,7 @@ def evaluate(gold_ud, system_ud, extraColumns) : correct[0] += 1 else : errors.append(words) - # WARNING: this script ignore examples where gold value == 0.0 - elif float(goldItem) != 0.0 : + else : correct[0] -= abs(float(goldItem) - float(systemItem))**1 correct[1] -= abs(float(goldItem) - float(systemItem))**2 goldValues.append(float(goldItem)) -- GitLab