From d6a28bc7ad3339ea1cf352ec62e331e45a4aeba3 Mon Sep 17 00:00:00 2001 From: Patrick Simianer Date: Mon, 3 Mar 2014 19:10:50 +0100 Subject: geoquery scripts + example --- scripts/geoquery/eval.rb | 17 +++++++++++++++++ scripts/geoquery/query.rb | 11 +++++++++++ scripts/geoquery/semparse.rb | 11 +++++++++++ 3 files changed, 39 insertions(+) create mode 100755 scripts/geoquery/eval.rb create mode 100755 scripts/geoquery/query.rb create mode 100755 scripts/geoquery/semparse.rb (limited to 'scripts') diff --git a/scripts/geoquery/eval.rb b/scripts/geoquery/eval.rb new file mode 100755 index 0000000..e605fa5 --- /dev/null +++ b/scripts/geoquery/eval.rb @@ -0,0 +1,17 @@ +#!/usr/bin/env ruby + +require 'nlp_ruby' + + +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/geoquery/query.rb b/scripts/geoquery/query.rb new file mode 100755 index 0000000..9cec355 --- /dev/null +++ b/scripts/geoquery/query.rb @@ -0,0 +1,11 @@ +#!/usr/bin/env ruby + +require 'nlp_ruby' + + +EVAL_PL='/workspace/grounded/wasp-1.0/data/geo-funql/eval/eval.pl' + +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 new file mode 100755 index 0000000..ebcbfbe --- /dev/null +++ b/scripts/geoquery/semparse.rb @@ -0,0 +1,11 @@ +#!/usr/bin/env ruby + +require 'nlp_ruby' + + +SMT_SEMPARSE = 'python /workspace/grounded/smt-semparse-cp/decode_sentence.py /workspace/grounded/smt-semparse-cp/working/full_dataset' + +while line = STDIN.gets + puts `#{SMT_SEMPARSE} "#{line}"` +end + -- cgit v1.2.3