diff options
author | Patrick Simianer <p@simianer.de> | 2016-05-03 14:22:32 +0200 |
---|---|---|
committer | Patrick Simianer <p@simianer.de> | 2016-05-03 14:22:32 +0200 |
commit | 7829b5c7a6f82121b013d819aad3e8239cd2596f (patch) | |
tree | 9fa55fa3eea4f079357d44a3608f761d0a695976 /server.rb | |
parent | b74ed595f149986474931f9328f84348a5652730 (diff) |
fixes
Diffstat (limited to 'server.rb')
-rwxr-xr-x | server.rb | 31 |
1 files changed, 24 insertions, 7 deletions
@@ -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 |