From b31ace79ea5f6b3f279c544cd3a443d6fbf2a24d Mon Sep 17 00:00:00 2001 From: Patrick Simianer Date: Thu, 26 Feb 2026 10:05:59 +0000 Subject: overhaul --- cumul | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'cumul') diff --git a/cumul b/cumul index 93a7e90..45ff03e 100755 --- a/cumul +++ b/cumul @@ -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 - -- cgit v1.2.3