diff options
author | Jacob <andqso@gmail.com> | 2013-07-28 09:54:54 +0100 |
---|---|---|
committer | Jacob <andqso@gmail.com> | 2013-07-28 09:54:54 +0100 |
commit | f343459d6198352964dbb6779f15c352fe2d5794 (patch) | |
tree | 07d50c9a8269e3892ccea8f5680b3e2bac984fce /src/bleu_scorer.py |
init
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() |