From 605e346327abc785c15772ad370f87c71f8741cc Mon Sep 17 00:00:00 2001 From: tosemml <97384583+tosemml@users.noreply.github.com> Date: Tue, 8 Aug 2023 14:59:32 -0700 Subject: [PATCH 1/4] use np.add --- bleu.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bleu.py b/bleu.py index f8f2b0a..dd01a14 100644 --- a/bleu.py +++ b/bleu.py @@ -20,6 +20,7 @@ import sys, math, re, xml.sax.saxutils import subprocess import os +import numpy as np # Added to bypass NIST-style pre-processing of hyp and ref files -- wade nonorm = 0 @@ -186,7 +187,7 @@ def bleuFromMaps(m1, m2): for key in m1: if key in m2: bl = bleu(m1[key], m2[key][0]) - score = [ score[i] + bl[i] for i in range(0, len(bl))] + score = np.add(score,bl) num += 1 return [s * 100.0 / num for s in score] From 8f0b9807d5c7b2fdb6ab15bce2483ed293ede42e Mon Sep 17 00:00:00 2001 From: tosemml <97384583+tosemml@users.noreply.github.com> Date: Tue, 8 Aug 2023 15:00:55 -0700 Subject: [PATCH 2/4] use np.add --- experiment/bleu.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/experiment/bleu.py b/experiment/bleu.py index f8f2b0a..dd01a14 100644 --- a/experiment/bleu.py +++ b/experiment/bleu.py @@ -20,6 +20,7 @@ import sys, math, re, xml.sax.saxutils import subprocess import os +import numpy as np # Added to bypass NIST-style pre-processing of hyp and ref files -- wade nonorm = 0 @@ -186,7 +187,7 @@ def bleuFromMaps(m1, m2): for key in m1: if key in m2: bl = bleu(m1[key], m2[key][0]) - score = [ score[i] + bl[i] for i in range(0, len(bl))] + score = np.add(score,bl) num += 1 return [s * 100.0 / num for s in score] From 9c1838d5d8173a3506b4a4d768ec938437616668 Mon Sep 17 00:00:00 2001 From: tosemml <97384583+tosemml@users.noreply.github.com> Date: Tue, 8 Aug 2023 15:03:14 -0700 Subject: [PATCH 3/4] use np.add --- experiment/code-to-text/code/bleu.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/experiment/code-to-text/code/bleu.py b/experiment/code-to-text/code/bleu.py index f8f2b0a..f737451 100644 --- a/experiment/code-to-text/code/bleu.py +++ b/experiment/code-to-text/code/bleu.py @@ -20,7 +20,7 @@ import sys, math, re, xml.sax.saxutils import subprocess import os - +import numpy as np # Added to bypass NIST-style pre-processing of hyp and ref files -- wade nonorm = 0 @@ -186,7 +186,7 @@ def bleuFromMaps(m1, m2): for key in m1: if key in m2: bl = bleu(m1[key], m2[key][0]) - score = [ score[i] + bl[i] for i in range(0, len(bl))] + score = np.add(score,bl) num += 1 return [s * 100.0 / num for s in score] From ffa41204a4b4a9d483c4d578c9ff4bb284b84121 Mon Sep 17 00:00:00 2001 From: tosemml <97384583+tosemml@users.noreply.github.com> Date: Tue, 8 Aug 2023 15:05:13 -0700 Subject: [PATCH 4/4] use np.add --- experiment/code-to-text/evaluator/evaluator.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/experiment/code-to-text/evaluator/evaluator.py b/experiment/code-to-text/evaluator/evaluator.py index f8f2b0a..dd01a14 100644 --- a/experiment/code-to-text/evaluator/evaluator.py +++ b/experiment/code-to-text/evaluator/evaluator.py @@ -20,6 +20,7 @@ import sys, math, re, xml.sax.saxutils import subprocess import os +import numpy as np # Added to bypass NIST-style pre-processing of hyp and ref files -- wade nonorm = 0 @@ -186,7 +187,7 @@ def bleuFromMaps(m1, m2): for key in m1: if key in m2: bl = bleu(m1[key], m2[key][0]) - score = [ score[i] + bl[i] for i in range(0, len(bl))] + score = np.add(score,bl) num += 1 return [s * 100.0 / num for s in score]