From 7829b5c7a6f82121b013d819aad3e8239cd2596f Mon Sep 17 00:00:00 2001 From: Patrick Simianer Date: Tue, 3 May 2016 14:22:32 +0200 Subject: fixes --- server.rb | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/server.rb b/server.rb index 5a95131..9ca43b1 100755 --- a/server.rb +++ b/server.rb @@ -34,7 +34,7 @@ $oov_corrected.default = false # ############################################################################# # Daemons # ############################################################################# -DIR="/fast_scratch/simianer/lfpe" +DIR="/srv/postedit" $daemons = { :tokenizer => "#{DIR}/lfpe/util/nanomsg_wrapper.rb -a tokenize -S '__ADDR__' -e #{EXTERNAL} -l #{TARGET_LANG}", :tokenizer_src => "#{DIR}/lfpe/util/nanomsg_wrapper.rb -a tokenize -S '__ADDR__' -e #{EXTERNAL} -l #{SOURCE_LANG}", @@ -123,6 +123,8 @@ def init $env[name] = { :socket => sock, :pid => pid } port += 1 } + + send_recv :truecaser, "lOaD iT" # lock file `touch #{LOCK_FILE}` $status = "Initialized" # status @@ -406,7 +408,7 @@ def process_next reply end # - known rules logmsg :server, "annotating known rules" - $status = "Adding rules to grammar" # status + $status = "Adding rules to the grammar" # status match = {} $known_rules.each { |r| _,src,tgt,_,_ = splitpipe r @@ -423,11 +425,16 @@ def process_next reply } WriteFile.new(grammar).write all_rules.join("\n")+"\n" # - additional rules - $new_rules.each { |rule| - logmsg :server, "adding rule '#{rule}' to grammar '#{grammar}'" - s = splitpipe(rule)[1..2].map{|i|i.strip.lstrip}.join(" ||| ") - `echo "#{rule}" >> #{grammar}` - } + logmsg :server, $new_rules.to_s + if $new_rules.size > 0 + s = $new_rules.join "\n" + `echo "#{s}" >> #{grammar}` + end + #$new_rules.each { |rule| + # logmsg :server, "adding rule '#{rule}' to grammar '#{grammar}'" + # s = splitpipe(rule)[1..2].map{|i|i.strip.lstrip}.join(" ||| ") + # `echo "#{rule}" >> #{grammar}` + #} # 2. check for OOVs if !$oov_corrected[$db['progress']] $status = "Checking for OOVs" # status @@ -664,11 +671,21 @@ get '/reset_extractor' do # reset grammar extractor return "reset extractor: done" end +get '/reset_grammars' do # reset grammar extractor + logmsg :server, "reset grammars" + return "locked" if $lock + `cp #{SESSION_DIR}/g/original/* #{SESSION_DIR}/g/` + $last_reply = nil + + return "reset grammars: done" +end + get '/reset_new_rules' do # removed learned rules $new_rules.clear $known_rules.clear `rm #{WORK_DIR}/*.*_rules` `rm #{WORK_DIR}/g/*` + $last_reply = nil return "reset new rules: done" end -- cgit v1.2.3