diff --git a/meteor/meteor.py b/meteor/meteor.py index 61916f4..a9d5775 100755 --- a/meteor/meteor.py +++ b/meteor/meteor.py @@ -62,15 +62,12 @@ def _score(self, hypothesis_str, reference_list): # SCORE ||| reference 1 words ||| reference n words ||| hypothesis words hypothesis_str = hypothesis_str.replace('|||','').replace(' ',' ') score_line = ' ||| '.join(('SCORE', ' ||| '.join(reference_list), hypothesis_str)) - self.meteor_p.stdin.write('{}\n'.format(score_line)) - stats = self.meteor_p.stdout.readline().strip() + self.meteor_p.stdin.write('{}\n'.format(score_line).encode()) + stats = self.meteor_p.stdout.readline().decode().strip() eval_line = 'EVAL ||| {}'.format(stats) # EVAL ||| stats - self.meteor_p.stdin.write('{}\n'.format(eval_line)) - score = float(self.meteor_p.stdout.readline().strip()) - # bug fix: there are two values returned by the jar file, one average, and one all, so do it twice - # thanks for Andrej for pointing this out - score = float(self.meteor_p.stdout.readline().strip()) + self.meteor_p.stdin.write('{}\n'.format(eval_line).encode()) + score = float(self.meteor_p.stdout.readline().decode().strip()) self.lock.release() return score