summaryrefslogtreecommitdiff
path: root/per_sentence_ter
diff options
context:
space:
mode:
authorPatrick Simianer <p@simianer.de>2014-02-16 00:25:49 +0100
committerPatrick Simianer <p@simianer.de>2014-02-16 00:25:49 +0100
commit4680f4a3178a9d630377116d38bd5412468c0d7a (patch)
tree50cc10100eba2991c4dc49224eb4f790a8aabadd /per_sentence_ter
parent81a637ae52d2a1d0bc751b44c193765cdc1091f1 (diff)
per sentence ...
Diffstat (limited to 'per_sentence_ter')
-rwxr-xr-xper_sentence_ter35
1 files changed, 35 insertions, 0 deletions
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
+