input is list of strings, not file paths
Browse files
gleu.py
CHANGED
@@ -78,21 +78,20 @@ class GLEU():
|
|
78 |
|
79 |
def load_hypothesis_sentence(self,hypothesis) :
|
80 |
self.hlen = len(hypothesis)
|
81 |
-
self.this_h_ngrams = [
|
82 |
-
|
83 |
|
84 |
-
def load_sources(self,
|
85 |
-
self.all_s_ngrams = [
|
86 |
for n in range(1,self.order+1) ]
|
87 |
-
|
88 |
|
89 |
-
def load_references(self,
|
90 |
self.refs = [ [] for i in range(len(self.all_s_ngrams)) ]
|
91 |
self.rlens = [ [] for i in range(len(self.all_s_ngrams)) ]
|
92 |
-
for
|
93 |
-
|
94 |
-
|
95 |
-
self.rlens[i].append(len(line.split()))
|
96 |
|
97 |
# count number of references each n-gram appear sin
|
98 |
self.all_rngrams_freq = [ Counter() for i in range(self.order) ]
|
|
|
78 |
|
79 |
def load_hypothesis_sentence(self,hypothesis) :
|
80 |
self.hlen = len(hypothesis)
|
81 |
+
self.this_h_ngrams = [self.get_ngram_counts(hypothesis,n)
|
82 |
+
for n in range(1,self.order+1) ]
|
83 |
|
84 |
+
def load_sources(self,source_sents) :
|
85 |
+
self.all_s_ngrams = [[self.get_ngram_counts(source_sent.split(),n)
|
86 |
for n in range(1,self.order+1) ]
|
87 |
+
for source_sent in source_sents ]
|
88 |
|
89 |
+
def load_references(self,ref_sents) :
|
90 |
self.refs = [ [] for i in range(len(self.all_s_ngrams)) ]
|
91 |
self.rlens = [ [] for i in range(len(self.all_s_ngrams)) ]
|
92 |
+
for i, ref_sent in enumerate(ref_sents) :
|
93 |
+
self.refs[i].append(ref_sent.split())
|
94 |
+
self.rlens[i].append(len(ref_sent.split()))
|
|
|
95 |
|
96 |
# count number of references each n-gram appear sin
|
97 |
self.all_rngrams_freq = [ Counter() for i in range(self.order) ]
|