diff options
| author | Patrick Simianer <patrick@lilt.com> | 2026-02-26 10:05:59 +0000 |
|---|---|---|
| committer | Patrick Simianer <patrick@lilt.com> | 2026-02-26 10:05:59 +0000 |
| commit | b31ace79ea5f6b3f279c544cd3a443d6fbf2a24d (patch) | |
| tree | 31f2b599fa5f6996aeb134390d58deb63eefe04a /cumul | |
| parent | 8805e95ae94d798c6441f7e1b72c90e049563f17 (diff) | |
Diffstat (limited to 'cumul')
| -rwxr-xr-x | cumul | 17 |
1 files changed, 9 insertions, 8 deletions
@@ -1,6 +1,7 @@ #!/usr/bin/env ruby -require 'zipf' +require "zipf" +require "tempfile" f = ReadFile.new ARGV[0] g = ReadFile.new ARGV[1] @@ -17,16 +18,16 @@ while line = f.gets sys1 << line1 sys2 << line2 - ff=File.new("/tmp/refs",'w+');ff.write(refs.join(""));ff.close - ff=File.new("/tmp/sys1",'w+');ff.write(sys1.join(""));ff.close - ff=File.new("/tmp/sys2",'w+');ff.write(sys2.join(""));ff.close + 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 = `~/multi-bleu.perl /tmp/refs < /tmp/sys1`.split[2].gsub(',','').to_f - a = BLEU::bleu("/tmp/sys1", "/tmp/refs", 4) - b = BLEU::bleu("/tmp/sys2", "/tmp/refs", 4) + 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 - |
