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] 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] 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] 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]