diff options
Diffstat (limited to 'src/bleu_scorer.py')
-rw-r--r-- | src/bleu_scorer.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/bleu_scorer.py b/src/bleu_scorer.py new file mode 100644 index 0000000..0b0da55 --- /dev/null +++ b/src/bleu_scorer.py @@ -0,0 +1,17 @@ +import os +import subprocess +import sys + +class BLEUScorer: + + def __init__(self, config): + self.config = config + + def run(self): + args = [self.config.bleu_eval, '%s/test.nl' % self.config.experiment_dir] + infile = open('%s/hyp.nl' % self.config.experiment_dir) + nullfile = open(os.devnull, 'w') + p = subprocess.Popen(args, stdin=infile, stdout=sys.stdout, stderr=nullfile) + p.wait() + infile.close() + nullfile.close() |