summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--js/lfpe.js14
-rwxr-xr-xserver.rb34
-rwxr-xr-xutil/wrapper.rb2
-rw-r--r--views/debug.haml36
4 files changed, 69 insertions, 17 deletions
diff --git a/js/lfpe.js b/js/lfpe.js
index e2b0f42..edfae9b 100644
--- a/js/lfpe.js
+++ b/js/lfpe.js
@@ -162,23 +162,31 @@ function Next()
// post edit
var post_edit = '';
+ var send_data = new Object();
// extract data from interfaces
if (ui_type == 'g') {
- post_edit = trim(JSON.parse(DE_extract_data())["target"].join(" "))
+ send_data = JSON.parse(DE_extract_data());
+ post_edit = trim(send_data["target"].join(" "));
+ send_data["post_edit"] = post_edit;
} else {
post_edit = trim(target_textarea.value);
+ send_data["post_edit"] = post_edit;
}
// send data
// ???
if (oov_correct.value=="false" && post_edit != "") {
+ send_data["duration"] = Timer.get();
+ send_data["source_value"] = source.value;
// compose request
- next_url += "&example="+encodeURIComponent(source.value)+"%20%7C%7C%7C%20"+encodeURIComponent(post_edit)+"&duration="+Timer.get();
+ //next_url += "&example="+encodeURIComponent(source.value)+"%20%7C%7C%7C%20"+encodeURIComponent(post_edit)+"&duration="+Timer.get();
// no change?
if (post_edit == last_post_edit.value) {
- next_url += "&nochange=1";
+ //next_url += "&nochange=1";
+ send_data["nochange"] = true;
}
+ next_url += "&example="+encodeURIComponent(JSON.stringify(send_data));
// update document overview
document.getElementById("seg_"+(current_seg_id.value)+"_t").innerHTML=post_edit;
// OOV correction mode
diff --git a/server.rb b/server.rb
index 6b81b36..b0da33a 100755
--- a/server.rb
+++ b/server.rb
@@ -174,11 +174,16 @@ get '/next' do # (receive post-edit, update models), send next translation
# 5d. actual update
# 6. update database
if params[:example]
+ logmsg :server, params[:example]
+ rcv_obj = JSON.parse params[:example]
# 0. save raw post-edit
- source, reference = params[:example].strip.split(" ||| ")
+ #source, reference = params[:example].strip.split(" ||| ")
+ source = rcv_obj["source_value"]
+ reference = rcv_obj["target"].join " "
reference = cleanstr(reference)
+ $db['feedback'] << params[:example]
$db['post_edits_raw'] << reference.strip
- $db['durations'] << params['duration'].to_i
+ $db['durations'] << rcv_obj['duration'].to_i
# 1. tokenize
reference = send_recv :tokenizer, reference
# 2. truecase
@@ -187,7 +192,7 @@ get '/next' do # (receive post-edit, update models), send next translation
logmsg :db, "saving processed post-edit"
$db['post_edits'] << reference.strip
nochange = false
- if params[:nochange]
+ if rcv_obj[:nochange]
logmsg :server, "no change -> no updates!"
nochange = true
end
@@ -210,8 +215,11 @@ get '/next' do # (receive post-edit, update models), send next translation
send_recv :extractor, "default_context ||| #{source} ||| #{reference} ||| #{a}"
# 6. update database
logmsg :db, "updating database"
+ $db['updated'] << true
+ else
+ $db['updated'] << false
end
- update_database
+ update_database
end
source = $db['source_segments'][$db['progress']]
raw_source = $db['raw_source_segments'][$db['progress']]
@@ -284,7 +292,8 @@ get '/next' do # (receive post-edit, update models), send next translation
end
# 3. translation
msg = "act:translate ||| <seg grammar=\"#{grammar}\"> #{source} </seg>"
- obj_str = proc_deriv(send_recv(:dtrain, msg))
+ deriv_s = send_recv(:dtrain, msg)
+ obj_str = proc_deriv(deriv_s)
obj = JSON.parse obj_str
obj["transl"] = obj["target_groups"].join " "
# 4. detokenizer
@@ -305,8 +314,10 @@ get '/next' do # (receive post-edit, update models), send next translation
obj["source_groups"][j][0]=prev if j > 0
}
# save
- $db["mt_raw"] = obj["transl"]
- $db["mt"] = obj["transl_detok"]
+ $db["derivations"] << deriv_s
+ $db["derivations_proc"] << obj_str
+ $db["mt_raw"] << obj["transl"]
+ $db["mt"] << obj["transl_detok"]
# 5. reply
$last_reply = obj.to_json
$lock = false
@@ -367,8 +378,15 @@ get '/reset' do # reset current session
$db = JSON.parse ReadFile.read DB_FILE
$db['post_edits'].clear
$db['post_edits_raw'].clear
+ $db['mt'].clear
+ $db['mt_raw'].clear
+ $db['updated'].clear
+ $db['durations'].clear
+ $db['derivations'].clear
+ $db['derivations_proc'].clear
+ $db['feedback'].clear
+ $db['progress'] = -1
update_database
- $db['progress'] = 0
$confirmed = true
$last_reply = nil
diff --git a/util/wrapper.rb b/util/wrapper.rb
index b760333..d0e6ca7 100755
--- a/util/wrapper.rb
+++ b/util/wrapper.rb
@@ -22,7 +22,7 @@ if conf[:action] == "detokenize"
STDERR.write "[detokenizer] No language given, exiting!\n"; exit
end
elsif conf[:action] == "tokenize"
- cmd = "#{conf[:ext]}/tokenizer-no-escape.perl -q -b -a -l #{conf[:lang]}"
+ cmd = "#{conf[:ext]}/tokenizer-no-escape.perl -q -b -l #{conf[:lang]}"
if !conf[:lang]
STDERR.write "[tokenizer] No language given, exiting!\n"; exit
end
diff --git a/views/debug.haml b/views/debug.haml
index 7e8b164..5b7ad20 100644
--- a/views/debug.haml
+++ b/views/debug.haml
@@ -5,7 +5,7 @@
%title debug view (session ##{session_key})
%link(rel="stylesheet" type="text/css" href="debug.css")
%script{:src =>"http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js", :charset=>"utf-8"}
- %script{:src => "http://coltrane.cl.uni-heidelberg.de/lfpe/js/debug.js"}
+ %script{:src => "http://postedit.cl.uni-heidelberg.de/js/debug.js"}
%body
%h1 debug view
%h2 session ##{session_key}
@@ -36,27 +36,53 @@
%table
%tr
%td.noborder
+ %strong progress:
+ %td.left #{[0,data2["progress"]-1].max}
+ %tr
+ %td.noborder
%strong source:
- %td.left #{data["source"]}
+ %td.left #{data2["source_segments"][[0,data2["progress"]-1].max]}
+ %tr
+ %td.noborder
+ %strong source (original):
+ %td.left #{data2["raw_source_segments"][[0,data2["progress"]-1].max]}
%tr
%td.noborder
%strong post-edit:
- %td.left #{data["target"]}
+ %td.left #{data2["post_edits_raw"][data2["progress"]-1]}
+ %tr
+ %td.noborder
+ %strong post-edit (processed):
+ %td.left #{data2["post_edits"][data2["progress"]-1]}
%tr
%td.noborder
%strong original mt:
- %td.left #{data["1best"]}
+ %td.left #{data2["mt_raw"][data2["progress"]-1]}
+ %tr
+ %td.noborder
+ %strong shown mt:
+ %td.left #{data2["mt"][data2["progress"]-1]}
%tr
%td.noborder
%strong best match (bleu=#{data["best_match_score"]}):
%td.left #{data["best_match"]}
+ %h2 derivation
+ %pre #{data2["derivations"][data2["progress"]-1]}
+ %p
+ %strong processed
+ - if data2["derivations_proc"][data2["progress"]-1]
+ %pre #{JSON.pretty_generate(JSON.parse(data2["derivations_proc"][data2["progress"]-1]))}
+ %h2 manual update
+ - if data2["feedback"][data2["progress"]-1]
+ %pre #{JSON.pretty_generate(JSON.parse(data2["feedback"][data2["progress"]-1]))}
%h2 meta
%p <strong>k:</strong> #{data["samples_size"]}
%p <strong>number of updates:</strong> #{data["num_up"]}
%p <strong>updated features:</strong> #{data["updated_features"]}
%p <strong>learning rate:</strong> #{data["learning_rate"]}
%p <strong>learning rate (sparse):</strong> #{data["learning_rate_sparse"]}
- %p <strong>duration:</strong> #{data2["durations"][[data2["progress"].to_i-1].max]}ms
+ %p <strong>duration:</strong> #{data2["durations"][data2["progress"].to_i-1]}ms
+ %p <strong>updated:</strong> #{data2["updated"][data2["progress"].to_i-1]}
%h2
additional rules (forced rules)
%pre #{additional_rules.join("\n")}