From 2b1d7f881c19c4d4b5afae194e02d3300c7675d0 Mon Sep 17 00:00:00 2001 From: Patrick Simianer Date: Tue, 5 Jul 2016 11:01:46 +0200 Subject: mv --- per-sentence-bleu-kbest | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100755 per-sentence-bleu-kbest (limited to 'per-sentence-bleu-kbest') diff --git a/per-sentence-bleu-kbest b/per-sentence-bleu-kbest new file mode 100755 index 0000000..f8bd860 --- /dev/null +++ b/per-sentence-bleu-kbest @@ -0,0 +1,32 @@ +#!/usr/bin/env ruby + +require 'zipf' +require 'trollop' + +def main + conf = Trollop::options do + opt :kbests, "kbests", :type => :string, :default => '-' + opt :references, "references", :type => :string, :required => true + end + refs = ReadFile.new conf[:references] + kbest_lists = read_kbest_lists conf[: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 + -- cgit v1.2.3