summaryrefslogtreecommitdiff
path: root/cumul
blob: 45ff03e3778ce82e96ac528685da9dae94f72356 (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
#!/usr/bin/env ruby

require "zipf"
require "tempfile"

f =  ReadFile.new ARGV[0]
g =  ReadFile.new ARGV[1]
h = ReadFile.new ARGV[2]

refs = []
sys1 = []
sys2 = []
diffs = []
while line = f.gets
  line1 = g.gets
  line2 = h.gets
  refs << line
  sys1 << line1
  sys2 << line2

  tmp_refs = Tempfile.new("refs"); tmp_refs.write(refs.join("")); tmp_refs.close
  tmp_sys1 = Tempfile.new("sys1"); tmp_sys1.write(sys1.join("")); tmp_sys1.close
  tmp_sys2 = Tempfile.new("sys2"); tmp_sys2.write(sys2.join("")); tmp_sys2.close

  a = BLEU::bleu(tmp_sys1.path, tmp_refs.path, 4)
  b = BLEU::bleu(tmp_sys2.path, tmp_refs.path, 4)

  tmp_refs.unlink; tmp_sys1.unlink; tmp_sys2.unlink
  diffs << b-a

  #puts ((diffs.inject(:+)/diffs.size)*100).round 2
  puts (diffs[-1]*100).round 2
end