diff --git a/nlgeval/pycocoevalcap/meteor/meteor.py b/nlgeval/pycocoevalcap/meteor/meteor.py index 5ed4a2f..fda124a 100755 --- a/nlgeval/pycocoevalcap/meteor/meteor.py +++ b/nlgeval/pycocoevalcap/meteor/meteor.py @@ -7,6 +7,7 @@ import atexit import logging import os +import re import subprocess import sys import threading @@ -99,8 +100,9 @@ def method(self): def _stat(self, hypothesis_str, reference_list): # SCORE ||| reference 1 words ||| reference n words ||| hypothesis words - hypothesis_str = hypothesis_str.replace('|||', '').replace(' ', ' ') + hypothesis_str = hypothesis_str.replace('|||', '') score_line = ' ||| '.join(('SCORE', ' ||| '.join(reference_list), hypothesis_str)) + score_line = re.sub(r'\s+', ' ', score_line) self.meteor_p.stdin.write(enc(score_line)) self.meteor_p.stdin.write(enc('\n')) self.meteor_p.stdin.flush()