summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Simianer <simianer@cl.uni-heidelberg.de>2014-02-16 01:34:00 +0100
committerPatrick Simianer <simianer@cl.uni-heidelberg.de>2014-02-16 01:34:00 +0100
commit0ed17a3cdf2698e868cd88881c1ba8cf99854baa (patch)
treef8c0c9e4fdac1c5334e51e289fd6e23e07b81d66
parent90d59cc7f850eaa91e963ef56050334e8ce8c568 (diff)
" -> '
-rwxr-xr-xrampfion.rb22
1 files changed, 11 insertions, 11 deletions
diff --git a/rampfion.rb b/rampfion.rb
index f067316..479ca2b 100755
--- a/rampfion.rb
+++ b/rampfion.rb
@@ -9,27 +9,27 @@ require_relative './hopefear'
SMT_SEMPARSE = 'python /workspace/grounded/smt-semparse-cp/decode_sentence.py /workspace/grounded/smt-semparse-cp/working/full_dataset'
EVAL_PL = '/workspace/grounded/wasp-1.0/data/geo-funql/eval/eval.pl'
-$cache = Memcached.new("localhost:11211")
+$cache = Memcached.new('localhost:11211')
def exec natural_language_string, reference_output, no_output=false
mrl = output = feedback = nil
- key_prefix = natural_language_string.encode("ASCII", :invalid => :replace, :undef => :replace, :replace => "?").gsub(/ /,'_')
+ key_prefix = natural_language_string.encode('ASCII', :invalid => :replace, :undef => :replace, :replace => '?').gsub(/ /,'_')
begin
- mrl = $cache.get key_prefix+"__MRL"
- output = $cache.get key_prefix+"__OUTPUT"
- feedback = $cache.get key_prefix+"__FEEDBACK"
+ mrl = $cache.get key_prefix+'__MRL'
+ output = $cache.get key_prefix+'__OUTPUT'
+ feedback = $cache.get key_prefix+'__FEEDBACK'
rescue Memcached::NotFound
mrl = spawn_with_timeout("#{SMT_SEMPARSE} \"#{natural_language_string}\" ", 60).strip
output = spawn_with_timeout("echo \"execute_funql_query(#{mrl}, X).\" | swipl -s #{EVAL_PL} 2>&1 | grep \"X =\"", 60).strip.split('X = ')[1]
feedback = output==reference_output
begin
- $cache.set key_prefix+"__MRL", mrl
- $cache.set key_prefix+"__OUTPUT", output
- $cache.set key_prefix+"__FEEDBACK", feedback
+ $cache.set key_prefix+'__MRL', mrl
+ $cache.set key_prefix+'__OUTPUT', output
+ $cache.set key_prefix+'__FEEDBACK', feedback
rescue SystemExit, Interrupt
- $cache.delete key_prefix+"__MRL"
- $cache.delete key_prefix+"__OUTPUT"
- $cache.delete key_prefix+"__FEEDBACK"
+ $cache.delete key_prefix+'__MRL'
+ $cache.delete key_prefix+'__OUTPUT'
+ $cache.delete key_prefix+'__FEEDBACK"'
end
end
STDERR.write " nrl: #{natural_language_string}\n" if !no_output