Skip to content
Snippets Groups Projects
Commit cd0e0326 authored by Franck Dary's avatar Franck Dary
Browse files

Fixed problem in conll18 eval where numeric column wasn't detected

parent 265848ed
No related branches found
No related tags found
No related merge requests found
......@@ -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))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment