From 053c878b5d627769b01b4aad5d90589b91866a52 Mon Sep 17 00:00:00 2001 From: Franck Dary <franck.dary@lis-lab.fr> Date: Mon, 29 Mar 2021 08:22:52 +0200 Subject: [PATCH] Avoid division by 0 in eval script --- scripts/conll18_ud_eval.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/conll18_ud_eval.py b/scripts/conll18_ud_eval.py index 371cbc1..5b76aaa 100755 --- a/scripts/conll18_ud_eval.py +++ b/scripts/conll18_ud_eval.py @@ -470,7 +470,9 @@ def evaluate(gold_ud, system_ud, extraColumns) : denom1 += (predictedValues[i]-predMean)**2 denom2 += (goldValues[i]-goldMean)**2 - pearson = numerator/((denom1**0.5)*(denom2**0.5)) + pearson = 0.0 + if denom1 > 0.0 and denom2 > 0.0 : + pearson = numerator/((denom1**0.5)*(denom2**0.5)) R2 = pearson**2 return [Score(gold, system, correct, aligned, isNumeric=isNumericOnly, R2=R2), errors] -- GitLab