venkatasg commited on
Commit
c94fbaa
·
1 Parent(s): 91c44b6
Files changed (1) hide show
  1. gleu.py +3 -4
gleu.py CHANGED
@@ -159,12 +159,11 @@ class GLEU():
159
  # smooth 0 counts for sentence-level scores
160
  if smooth :
161
  stats = [ s if s != 0 else 1 for s in stats ]
162
- if len(filter(lambda x: x==0, stats)) > 0:
163
  return 0
164
  (c, r) = stats[:2]
165
- log_gleu_prec = sum([math.log(float(x)/y)
166
- for x,y in zip(stats[2::2],stats[3::2])]) / 4
167
- return math.exp(min([0, 1-float(r)/c]) + log_gleu_prec)
168
 
169
 
170
 
 
159
  # smooth 0 counts for sentence-level scores
160
  if smooth :
161
  stats = [ s if s != 0 else 1 for s in stats ]
162
+ if len(list(filter(lambda x: x==0, stats))) > 0:
163
  return 0
164
  (c, r) = stats[:2]
165
+ log_gleu_prec = sum([log(float(x)/y) for x,y in zip(stats[2::2],stats[3::2])]) / 4
166
+ return exp(min([0, 1-float(r)/c]) + log_gleu_prec)
 
167
 
168
 
169