diff options
author | Patrick Simianer <p@simianer.de> | 2014-02-16 00:25:49 +0100 |
---|---|---|
committer | Patrick Simianer <p@simianer.de> | 2014-02-16 00:25:49 +0100 |
commit | 4680f4a3178a9d630377116d38bd5412468c0d7a (patch) | |
tree | 50cc10100eba2991c4dc49224eb4f790a8aabadd /per_sentence_bleu_kbest | |
parent | 81a637ae52d2a1d0bc751b44c193765cdc1091f1 (diff) |
per sentence ...
Diffstat (limited to 'per_sentence_bleu_kbest')
-rwxr-xr-x | per_sentence_bleu_kbest | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/per_sentence_bleu_kbest b/per_sentence_bleu_kbest new file mode 100755 index 0000000..475da03 --- /dev/null +++ b/per_sentence_bleu_kbest @@ -0,0 +1,34 @@ +#!/usr/bin/env ruby + +require 'nlp_ruby' +require 'trollop' + + +def main + cfg = Trollop::options do + opt :kbests, "kbests", :type => :string, :default => '-' + opt :references, "references", :type => :string, :required => true + end + refs = ReadFile.new cfg[:references] + kbest_lists = read_kbest_lists cfg[:kbests] + i = 0 + kbest_lists.each { |list| + scores = [] + o = false + list.each { |e| scores << per_sentence_bleu(e, refs[i]) } + max = scores.max + scores.each_with_index { |x,j| + puts "#{j+1} ||| #{scores[j]} ||| #{list[j]}" + if scores[j]==max && !o + puts "^^^ #{j+1} #{max}" + o = true + end + } + puts + i += 1 + } +end + + +main + |