blob: 4d821b357b68a7591e2597a328adc8854acaa0d8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
#!/usr/bin/env ruby
require 'zipf'
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
|