summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/free917/cv.sh61
-rw-r--r--scripts/free917/eval.rb17
-rw-r--r--scripts/free917/parse_utterance.rb42
-rw-r--r--scripts/free917/sigf_format.rb20
4 files changed, 140 insertions, 0 deletions
diff --git a/scripts/free917/cv.sh b/scripts/free917/cv.sh
new file mode 100644
index 0000000..a7d678d
--- /dev/null
+++ b/scripts/free917/cv.sh
@@ -0,0 +1,61 @@
+#!/bin/bash
+
+killall memcached
+memcached &
+
+K=100
+J=10
+SEMPRE=/path/to/sempre
+STOPWORDS=/path/to/stopwords.en
+CFG=/home/mitarb/haas1/caro/rebol/cfg.rb
+MODEL=1
+
+for VARIANT in rebol rampion exec; do
+for INI in /paths/to/cdec/inis; do
+for INIT_WEIGHTS in /paths/to/weight/files; do
+for E in 0.0001 0.0003 0.001 0.003 0.01 0.03 0.1 0.3; do
+
+NAME="v=$VARIANT.e=$E.c=$(basename $INI).w=$(basename $INIT_WEIGHTS).m=$MODEL/"
+
+cd $cwd
+mkdir $NAME
+
+for COUNT in #number of folds
+do
+ cd $cwd
+ cd $NAME
+ mkdir $COUNT
+ cd $COUNT
+ for DEV in #number of folds
+ do
+ if [ $COUNT != $DEV ]
+ then
+ cat /path/to/free917v2.$DEV.in >> free917v2.dev.in
+ cat /path/to/free917v2.$DEV.tok.en >> free917v2.dev.tok.en
+ cat /path/to/free917v2.$DEV.gold >> free917v2.dev.gold
+ cat /path/to/free917v2.$DEV.mrl >> free917v2.dev.mrl
+ fi
+ done
+ ../rebol.rb \
+ -k $K \
+ -i /path/tofree917v2.dev.in \
+ -r /path/tofree917v2.dev.tok.en \
+ -g /path/tofree917v2.dev.gold \
+ -h /path/tofree917v2.dev.mrl \
+ -w $INIT_WEIGHTS \
+ -c $INI \
+ -t $STOPWORDS \
+ -o $NAME.weights \
+ -b $CFG \
+ -l \
+ -e $E \
+ -j $J \
+ -u free917 \
+ -z $MODEL \
+ -v $VARIANT &> $NAME.output &
+
+done
+done
+done
+done
+done
diff --git a/scripts/free917/eval.rb b/scripts/free917/eval.rb
new file mode 100644
index 0000000..ccd8003
--- /dev/null
+++ b/scripts/free917/eval.rb
@@ -0,0 +1,17 @@
+#!/usr/bin/env ruby
+
+require 'zipf'
+
+
+gold = ReadFile.readlines_strip ARGV[0]
+i = j = correct = 0
+while line = STDIN.gets
+ line.strip!
+ correct += 1 if line==gold[i]
+ i += 1
+ j += 1 if line=='' # no parse
+end
+acc = correct.to_f/i
+prec = correct.to_f/(i-j)
+puts "acc=#{(100*acc).round 2} prec=#{(100*prec).round 2} (#{i}/#{j}) abs=#{correct} f1=#{(100*(2*acc*prec)/(acc+prec)).round 2}"
+
diff --git a/scripts/free917/parse_utterance.rb b/scripts/free917/parse_utterance.rb
new file mode 100644
index 0000000..1206c32
--- /dev/null
+++ b/scripts/free917/parse_utterance.rb
@@ -0,0 +1,42 @@
+#!/usr/bin/env ruby
+
+require 'pty'
+require 'expect'
+def query(string)
+ answer = "\n"
+ @in.printf("#{string}\n")
+ result = @out.expect(/^> /,timeout=30)
+ if result!=nil
+ result[0].delete!("\r\n")
+ result[0].delete!("\n")
+ result[0].delete!("\r")
+ matchData = result[0].match(/Top value { (.*) }>/)
+ if matchData!=nil
+ save = matchData[1].gsub(/^ */,"")
+ save = save.gsub(/ *$/,"")
+ save = save.gsub(/ +/," ")
+ answer = save+"\n"
+ end
+ end
+ STDOUT.write answer
+end
+
+def main
+ model = ARGV[0] #parser model to be used
+ lines = Array.new
+ answers = Array.new
+ original_dir = Dir.pwd
+ Dir.chdir ARGV[1] #location of sempre
+ @out, @in, @pid = PTY.spawn("./sempre @mode=interact @domain=free917 @sparqlserver=localhost:3093 @cacheserver=local @load=#{model} @executeTopOnly=0")
+ @out.expect(/^> /,timeout=300)[0]
+ @in.printf("initialize model\n")
+ result = @out.expect(/^> /,timeout=300)
+
+ Dir.chdir original_dir
+ while line = $stdin.gets
+ query(line.chomp)
+ end
+end
+
+main
+
diff --git a/scripts/free917/sigf_format.rb b/scripts/free917/sigf_format.rb
new file mode 100644
index 0000000..beac2e7
--- /dev/null
+++ b/scripts/free917/sigf_format.rb
@@ -0,0 +1,20 @@
+#!/usr/bin/env ruby
+
+require 'zipf'
+
+
+gold = ReadFile.readlines_strip ARGV[0]
+i = -1
+while line = STDIN.gets
+ i += 1
+ line.strip!
+ a = [0, 0, 1]
+ if line==gold[i]
+ a[0] = 1
+ a[1] = 1
+ elsif line!=''
+ a[1] = 1
+ end
+ puts a.join " "
+end
+