venkatasg commited on
Commit
8abe922
·
1 Parent(s): fc51350

xrange is from py2

Browse files
Files changed (1) hide show
  1. gleu.py +2 -3
gleu.py CHANGED
@@ -115,8 +115,7 @@ class GLEU():
115
  ngrams[nn] = new_ngrams[nn]
116
 
117
  def get_ngram_counts(self,sentence,n) :
118
- return Counter([tuple(sentence[i:i+n])
119
- for i in xrange(len(sentence)+1-n)])
120
 
121
  # returns ngrams in a but not in b
122
  def get_ngram_diff(self,a,b) :
@@ -141,7 +140,7 @@ class GLEU():
141
  yield hlen
142
  yield rlen
143
 
144
- for n in xrange(1,self.order+1):
145
  h_ngrams = self.this_h_ngrams[n-1]
146
  s_ngrams = self.all_s_ngrams[i][n-1]
147
  r_ngrams = self.get_ngram_counts(self.refs[i][r_ind],n)
 
115
  ngrams[nn] = new_ngrams[nn]
116
 
117
  def get_ngram_counts(self,sentence,n) :
118
+ return Counter([tuple(sentence[i:i+n]) for i in range(len(sentence)+1-n)])
 
119
 
120
  # returns ngrams in a but not in b
121
  def get_ngram_diff(self,a,b) :
 
140
  yield hlen
141
  yield rlen
142
 
143
+ for n in range(1,self.order+1):
144
  h_ngrams = self.this_h_ngrams[n-1]
145
  s_ngrams = self.all_s_ngrams[i][n-1]
146
  r_ngrams = self.get_ngram_counts(self.refs[i][r_ind],n)