From 8857a34ca0b673990211db8cec451ebaf9488917 Mon Sep 17 00:00:00 2001 From: Patrick Simianer
Date: Thu, 29 Oct 2015 17:45:32 +0100
Subject: server.rb: logging, better re-send condition, saving additional stuff
---
server.rb | 53 +++++++++++++++++++++++++++++++----------------------
1 file changed, 31 insertions(+), 22 deletions(-)
(limited to 'server.rb')
diff --git a/server.rb b/server.rb
index 8d45ca7..f5e2ddb 100755
--- a/server.rb
+++ b/server.rb
@@ -13,23 +13,24 @@ require_relative './derivation_to_json/derivation_to_json'
# Load configuration file and setup global variables
# #############################################################################
require_relative "#{ARGV[0]}" # load configuration for this session
-$lock = false # lock if currently learning/translating
-$last_reply = nil # cache last reply
-$confirmed = true # client received translation?
-$additional_rules = []
+$lock = false # lock if currently learning/translating
+$last_reply = nil # cache last reply
+$confirmed = true # client received translation?
+$additional_rules = [] # corrected OOVs
if !FileTest.exist? LOCK_FILE # locked?
- $db = {} # FIXME: that is supposed to be a database connection
+ $db = {} # data file (JSON format)
$env = {} # environment variables (socket connections to daemons)
end
# #############################################################################
# Daemons
# #############################################################################
-DIR="/fast_scratch/simianer/lfpe/"
+DIR="/fast_scratch/simianer/lfpe"
$daemons = {
:tokenizer => "#{DIR}/lfpe/util/wrapper.rb -a tokenize -S '__ADDR__' -e #{EXTERNAL} -l #{TARGET_LANG}",
:detokenizer => "#{DIR}/lfpe/util/wrapper.rb -a detokenize -S '__ADDR__' -e #{EXTERNAL} -l #{TARGET_LANG}",
:truecaser => "#{DIR}/lfpe/util/wrapper.rb -a truecase -S '__ADDR__' -e #{EXTERNAL} -t #{SESSION_DIR}/truecase.model",
+ #:lowercaser => "#{DIR}/lfpe/util/wrapper.rb -a lowercase -S '__ADDR__' -e #{EXTERNAL}",
:dtrain => "#{CDEC}/training/dtrain/dtrain_net_interface -c #{SESSION_DIR}/dtrain.ini -d #{WORK_DIR}/dtrain.debug.json -o #{WORK_DIR}/weights -a '__ADDR__' -E",
:extractor => "python -m cdec.sa.extract -c #{SESSION_DIR}/sa.ini --online -u -S '__ADDR__'",
:aligner_fwd => "#{CDEC}/word-aligner/net_fa -f #{SESSION_DIR}/forward.params -m #{FWD_MEAN_SRCLEN_MULT} -T #{FWD_TENSION} --sock_url '__ADDR__'",
@@ -79,7 +80,7 @@ end
def update_database
$db['progress'] += 1
- j = JSON.generate $db # FIXME: proper database
+ j = JSON.generate $db
f = WriteFile.new DB_FILE
f.write j.to_s
f.close
@@ -87,7 +88,7 @@ end
def init
# database connection
- $db = JSON.parse ReadFile.read DB_FILE # FIXME: proper database
+ $db = JSON.parse ReadFile.read DB_FILE
# working directory
`mkdir -p #{WORK_DIR}/g`
# setup environment, start daemons
@@ -139,7 +140,7 @@ get '/next' do # (receive post-edit, update models), send next translation
# already processing request?
return "locked" if $lock # return
$lock = true
- key = params[:key] # FIXME: do something with it, e.g. simple auth
+ key = params[:key] # TODO: do something with it, e.g. simple auth?
if params[:correct]
logmsg :server, "correct: #{params[:correct]}"
grammar = "#{WORK_DIR}/g/#{$db['progress']}.grammar"
@@ -190,15 +191,18 @@ get '/next' do # (receive post-edit, update models), send next translation
nochange = true
end
if !NOLEARN && !NOMT && !nochange
+ logmsg :server, "updating ..."
# 4. update weights
grammar = "#{WORK_DIR}/g/#{$db['progress']}.grammar"
annotated_source = "