From 4680f4a3178a9d630377116d38bd5412468c0d7a Mon Sep 17 00:00:00 2001 From: Patrick Simianer Date: Sun, 16 Feb 2014 00:25:49 +0100 Subject: per sentence ... --- per_sentence_ter | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 per_sentence_ter (limited to 'per_sentence_ter') diff --git a/per_sentence_ter b/per_sentence_ter new file mode 100755 index 0000000..eb7083b --- /dev/null +++ b/per_sentence_ter @@ -0,0 +1,35 @@ +#!/usr/bin/env ruby + +require 'nlp_ruby' +require 'trollop' +require 'tempfile' + + +def main + cfg = 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 cfg[:references] + input = ReadFile.new cfg[: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 + -- cgit v1.2.3