summaryrefslogtreecommitdiff
path: root/server.rb
diff options
context:
space:
mode:
authorPatrick Simianer <p@simianer.de>2016-02-17 18:05:27 +0100
committerPatrick Simianer <p@simianer.de>2016-02-17 18:05:27 +0100
commit53e8b1106a1ebaf13a5482477b67e04aacd4405d (patch)
treeabc62f03d0306a780a9f9cbf1a869925fdfc235f /server.rb
parentaa2832b55b1b9825ad626aa0483a97c5ba9c991c (diff)
prep/notes for beta test, get feature weights/rates
Diffstat (limited to 'server.rb')
-rwxr-xr-xserver.rb33
1 files changed, 32 insertions, 1 deletions
diff --git a/server.rb b/server.rb
index ad52b62..5fa291a 100755
--- a/server.rb
+++ b/server.rb
@@ -266,6 +266,9 @@ def process_next reply
s = splitpipe(rs)[1..2].map{|i|i.strip.lstrip}.join(" ||| ")
new_rules_ids.has_key?(s)
}
+ f = WriteFile.new "#{WORK_DIR}/#{$db['progress']}.known_rules"
+ f.write add_known_rules.join "\n"
+ f.close
$known_rules += add_known_rules
$known_rules.uniq! { |rs|
splitpipe(rs)[1..2].map{|i|i.strip.lstrip}.join(" ||| ")
@@ -324,7 +327,8 @@ def process_next reply
a = send_recv :atools, "#{a_fwd} ||| #{a_back}"
# 5d actual extractor
$status = "Updating grammar extractor" # status
- send_recv :extractor, "default_context ||| #{source} ||| #{post_edit} ||| #{a}"
+ msg = "default_context ||| #{source} ||| #{post_edit} ||| #{a}"
+ send_recv :extractor, msg
# 6. update database
$db['updated'] << true
`cp #{WORK_DIR}/dtrain.debug.json \
@@ -544,6 +548,13 @@ get '/status' do # check status
return $status
end
+get '/status_debug' do # check status
+ cross_origin
+ logmsg :server, "status: #{$status}"
+ return "[##{$db["progress"]}] Locked" if $locked
+ return "[##{$db["progress"]}] #{$status}"
+end
+
get '/confirm' do # client confirms received translation
cross_origin
$confirmed = true
@@ -572,6 +583,24 @@ get '/set_learning_rates/:name/:rate' do # set learning rates
return msg
end
+get '/get_weight/:name' do
+ name = params[:name].gsub " ", "_"
+ logmsg :server, "getting weight for '#{name}'"
+ return "locked" if $lock
+ msg = send_recv :dtrain, "get_weight #{name}"
+
+ return msg
+end
+
+get '/get_rate/:name' do
+ name = params[:name].gsub " ", "_"
+ logmsg :server, "getting rate for '#{name}'"
+ return "locked" if $lock
+ msg = send_recv :dtrain, "get_rate #{name}"
+
+ return msg
+end
+
get '/reset_weights' do # reset weights
logmsg :server, "reset weights"
return "locked" if $lock
@@ -622,6 +651,8 @@ end
get '/reset_new_rules' do # removed learned rules
$new_rules.clear
$known_rules.clear
+ `rm #{WORK_DIR}/*.*_rules`
+ `rm #{WORK_DIR}/g/*`
return "reset new rules: done"
end