From a04fad578a2067c0818d1f6a630f9fe120a9db6e Mon Sep 17 00:00:00 2001 From: Patrick Simianer
Date: Fri, 26 Jun 2015 15:21:37 +0200
Subject: small changes
---
server.rb | 49 ++++++++++++++++++++++++++++++++++++-------------
1 file changed, 36 insertions(+), 13 deletions(-)
diff --git a/server.rb b/server.rb
index b8bdd5f..8d615dc 100755
--- a/server.rb
+++ b/server.rb
@@ -5,7 +5,6 @@ require 'sinatra/cross_origin'
require "sinatra/reloader"
require 'nanomsg'
require 'zipf'
-require 'digest'
require 'json'
require 'haml'
@@ -27,8 +26,8 @@ end
$daemons = {
:tokenizer => "/fast_scratch/simianer/lfpe/lfpe/util/wrapper.rb -a tokenize -S '__ADDR__' -e #{EXTERNAL} -l #{TARGET_LANG}",
:detokenizer => "/fast_scratch/simianer/lfpe/lfpe/util/wrapper.rb -a detokenize -S '__ADDR__' -e #{EXTERNAL} -l #{TARGET_LANG}",
- :truecaser => "/fast_scratch/simianer/lfpe/lfpe/util/wrapper.rb -a truecase -S '__ADDR__' -e #{EXTERNAL} -t #{SESSION_DIR}/truecaser",
- :dtrain => "#{CDEC}/training/dtrain/dtrain_net_interface -c #{SESSION_DIR}/dtrain.ini -d #{WORK_DIR}/dtrain.debug.json -o #{WORK_DIR}/weights.final -a '__ADDR__'",
+ :truecaser => "/fast_scratch/simianer/lfpe/lfpe/util/wrapper.rb -a truecase -S '__ADDR__' -e #{EXTERNAL} -t #{SESSION_DIR}/truecase.model",
+ :dtrain => "#{CDEC}/training/dtrain/dtrain_net_interface -c #{SESSION_DIR}/dtrain.ini -d #{WORK_DIR}/dtrain.debug.json -o #{WORK_DIR}/weights -a '__ADDR__'",
: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__'",
:aligner_back => "#{CDEC}/word-aligner/net_fa -f #{SESSION_DIR}/backward.params -m #{BACK_MEAN_SRCLEN_MULT} -T #{BACK_TENSION} --sock_url '__ADDR__'",
@@ -78,7 +77,7 @@ end
def update_database
$db['progress'] += 1
- j = JSON.generate $db # FIXME: real database
+ j = JSON.generate $db # FIXME: proper database
f = WriteFile.new DB_FILE
f.write j.to_s
f.close
@@ -86,7 +85,7 @@ end
def init
# database connection
- $db = JSON.parse ReadFile.read DB_FILE # FIXME: real database
+ $db = JSON.parse ReadFile.read DB_FILE # FIXME: proper database
# working directory
`mkdir -p #{WORK_DIR}/g`
# setup environment, start daemons
@@ -101,7 +100,7 @@ def init
end
def send_recv daemon, msg # simple pair communcation
- socket = $env[daemon][:socket]
+ socket = $env[daemon][:socket] # query -> answer
logmsg daemon, "> sending message: '#{msg}'"
socket.send msg
logmsg daemon, "waiting ..."
@@ -122,7 +121,7 @@ init if !FileTest.exist?(LOCK_FILE)
get '/' do
cross_origin
- return ""
+ return "" # return
end
get '/next' do # (receive post-edit, update models), send next translation
@@ -130,7 +129,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
+ key = params[:key] # FIXME: do something with it, e.g. simple auth
# received post-edit -> update models
# 0. save raw post-edit
@@ -156,14 +155,14 @@ get '/next' do # (receive post-edit, update models), send next translation
logmsg "db", "saving processed post-edit"
$db['post_edits'] << reference.strip
# 4. update weights
- grammar = "#{WORK_DIR}/g/#{Digest::SHA256.hexdigest(source)}.grammar"
+ grammar = "#{WORK_DIR}/g/#{$db['progress']}.grammar"
annotated_source = "