diff options
Diffstat (limited to 'per-sentence-ter')
-rwxr-xr-x | per-sentence-ter | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/per-sentence-ter b/per-sentence-ter new file mode 100755 index 0000000..fa283ef --- /dev/null +++ b/per-sentence-ter @@ -0,0 +1,33 @@ +#!/usr/bin/env ruby + +require 'zipf' +require 'trollop' +require 'tempfile' + +def main + conf = Trollop::options do + opt :input, "input", :type => :string, :default => '-' + opt :references, "references", :type => :string, :required => true + opt :mteval_bin, "cdec's mteval/fast_score", :type => :string, :default => '`/toolbox/cdec-dtrain/mteval/fast_score' + end + + refs = ReadFile.readlines_strip conf[:references] + input = ReadFile.new conf[:input] + i = -1 + while line = input.gets + line.strip! + i += 1 + a = Tempfile.new 'pster' + b = Tempfile.new 'pster' + a.write line+"\n" + b.write refs[i]+"\n" + a.close; b.close + score = `/toolbox/cdec-dtrain/mteval/fast_score -i #{a.path} -r #{b.path} -m ter 2>/dev/null` + puts score + a.unlink; b.unlink + end + input.close +end + +main + |