From be45f7b253c23757449103ffe3005107ce9169fa Mon Sep 17 00:00:00 2001 From: Patrick Simianer Date: Tue, 1 Apr 2014 13:45:23 +0200 Subject: cv version --- lampion.rb | 8 ++++---- scripts/geoquery/query.rb | 4 +++- scripts/geoquery/semparse.rb | 4 +++- scripts/geoquery/test-nof-old.sh | 5 +++++ scripts/geoquery/test-nof.sh | 5 +++++ scripts/geoquery/test.sh | 5 +++++ scripts/geoquery/translate.sh | 4 ++++ 7 files changed, 29 insertions(+), 6 deletions(-) create mode 100755 scripts/geoquery/test-nof-old.sh create mode 100755 scripts/geoquery/test-nof.sh create mode 100755 scripts/geoquery/test.sh create mode 100755 scripts/geoquery/translate.sh diff --git a/lampion.rb b/lampion.rb index 00b5508..ab8861f 100755 --- a/lampion.rb +++ b/lampion.rb @@ -68,7 +68,7 @@ def adjust_model_scores kbest, factor min = kbest.map{ |k| k.scores[:decoder] }.min max = kbest.map{ |k| k.scores[:decoder] }.max return if min==0&&max==0 - kbest.each { |k| k.scores[:decoder] = factor*((k.scores[:decoder]-min)/(max-min)) } + kbest.each { |k| k.scores[:decoder_orig] = k.scores[:decoder]; k.scores[:decoder] = factor*((k.scores[:decoder]-min)/(max-min)) } end def main @@ -187,15 +187,15 @@ def main # get per-sentence BLEU scores kbest.each { |k| k.scores[:psb] = BLEU::per_sentence_bleu k.s, references[j] } + # map decoder scores to [0,1] + adjust_model_scores kbest, cfg[:scale_model] + if cfg[:print_kbest] STDERR.write "\n<<< KBEST\n" kbest.each_with_index { |k,l| STDERR.write k.to_s2+"\n" } STDERR.write ">>>\n" end - # map decoder scores to [0,1] - adjust_model_scores kbest, cfg[:scale_model] - # informative output STDERR.write "\n [TOP1]\n" # print 1best on last iteration diff --git a/scripts/geoquery/query.rb b/scripts/geoquery/query.rb index 25cded5..3b4b681 100755 --- a/scripts/geoquery/query.rb +++ b/scripts/geoquery/query.rb @@ -1,9 +1,11 @@ #!/usr/bin/env ruby require 'nlp_ruby' -require_relative '../../cfg.rb' +require 'memcached' +require_relative ARGV[0] + while line = STDIN.gets puts `echo "execute_funql_query(#{line}, X)." | swipl -s #{EVAL_PL} 2>&1 | grep "X ="`.gsub('X = ','').strip end diff --git a/scripts/geoquery/semparse.rb b/scripts/geoquery/semparse.rb index 9858ade..45fe98c 100755 --- a/scripts/geoquery/semparse.rb +++ b/scripts/geoquery/semparse.rb @@ -1,9 +1,11 @@ #!/usr/bin/env ruby require 'nlp_ruby' -require_relative '../../cfg.rb' +require 'memcached' +require_relative ARGV[0] + while line = STDIN.gets puts `#{SMT_SEMPARSE} "#{line}"` end diff --git a/scripts/geoquery/test-nof-old.sh b/scripts/geoquery/test-nof-old.sh new file mode 100755 index 0000000..99a8241 --- /dev/null +++ b/scripts/geoquery/test-nof-old.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +/workspace/grounded/lampion/scripts/geoquery/translate.sh $1 $2 < /workspace/grounded/lampion/proper/d/split880.test-nof-old.in | tee $2.transl | /workspace/grounded/lampion/scripts/geoquery/semparse.rb $3 | tee $2.parsed | /workspace/grounded/lampion/scripts/geoquery/query.rb $3 > $2.output +/workspace/grounded/lampion/scripts/geoquery/eval.rb /workspace/grounded/lampion/proper/d/split880.test-nof.gold < $2.output > $2.result + diff --git a/scripts/geoquery/test-nof.sh b/scripts/geoquery/test-nof.sh new file mode 100755 index 0000000..786afc2 --- /dev/null +++ b/scripts/geoquery/test-nof.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +/workspace/grounded/lampion/scripts/geoquery/translate.sh $1 $2 < /workspace/grounded/lampion/proper/d/split880.test-nof.in | tee $2.transl | /workspace/grounded/lampion/scripts/geoquery/semparse.rb $3 | tee $2.parsed | /workspace/grounded/lampion/scripts/geoquery/query.rb $3 > $2.output +/workspace/grounded/lampion/scripts/geoquery/eval.rb /workspace/grounded/lampion/proper/d/split880.test-nof.gold < $2.output > $2.result + diff --git a/scripts/geoquery/test.sh b/scripts/geoquery/test.sh new file mode 100755 index 0000000..3ac8b2d --- /dev/null +++ b/scripts/geoquery/test.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +/workspace/grounded/lampion/scripts/geoquery/translate.sh $1 $2 < /workspace/grounded/lampion/proper/d/split880.test.in | tee $2.transl | /workspace/grounded/lampion/scripts/geoquery/semparse.rb $3 | tee $2.parsed | /workspace/grounded/lampion/scripts/geoquery/query.rb $3 > $2.output +/workspace/grounded/lampion/scripts/geoquery/eval.rb /workspace/grounded/lampion/proper/d/split880.test.gold < $2.output > $2.result + diff --git a/scripts/geoquery/translate.sh b/scripts/geoquery/translate.sh new file mode 100755 index 0000000..af15aa1 --- /dev/null +++ b/scripts/geoquery/translate.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +/toolbox/cdec-dtrain/decoder/cdec -c $1 -w $2 2>/dev/null + -- cgit v1.2.3