From 53e8b1106a1ebaf13a5482477b67e04aacd4405d Mon Sep 17 00:00:00 2001 From: Patrick Simianer
Date: Wed, 17 Feb 2016 18:05:27 +0100 Subject: prep/notes for beta test, get feature weights/rates --- inc/help.inc.php | 32 ++++++++++++++---------- index.php | 45 +++++++++++++++++----------------- js/debug.js | 40 ++++++++++++++++++++++++++++-- js/interface.js | 4 +-- server.rb | 33 ++++++++++++++++++++++++- static/debug.css | 5 ++-- views/debug.haml | 75 +++++++++++++++++++++++++++++++++++++++----------------- 7 files changed, 168 insertions(+), 66 deletions(-) diff --git a/inc/help.inc.php b/inc/help.inc.php index 2bd511e..9f2e7f6 100644 --- a/inc/help.inc.php +++ b/inc/help.inc.php @@ -1,41 +1,47 @@
Press the 'Next' button to submit your post-edit and to request the next segment for post-edition. -Alternatively, in the textual interface, you may just press return when you finished the post-edit ('Target' text area is in focus).
+Alternatively, in the textual interface, you may just press return when the post-edit is finished ('Target' text area is focused). -The session can be paused at any time and continued later; However, if you have to pause your session, wait until the activity notification disappears and then press 'Pause', as we are collecting timing information. You may also just reload this site and re-request the segment to reset the timer.
+The session can be paused at any time and continued later; However, if you have to pause your session, wait until the activity notification disappears and then press 'Pause', as we are collecting timing information. You may also just reload this site upon your return and re-request the segment to reset the timer.
-Please use only a single browser window at the same time. Going back to earlier examples is not possible, please take great care when interacting with the system.
+Please use only a single browser window per session at the same time. Going back to earlier examples is not possible, please take great care when interacting with the system.
Instructions for the graphical interface:
-To submit a post-edition in the graphical interface all phrases have to be marked as finished.
+To submit a post-edition in the graphical interface all phrases have to be marked as finished (phrases are highlighted in dark gray color).
The interface was tested with Firefox 31, 38 and 43.
+The interface was tested with Firefox 31, 38 and 43.
Known issues:
Notes on debugging:
+Support: Mail
-Session: # | +
Session: | Debug
diff --git a/index.php b/index.php index 74d64a3..d10bc2e 100644 --- a/index.php +++ b/index.php @@ -26,37 +26,36 @@Beta test: diff --git a/js/debug.js b/js/debug.js index 3fab4c7..cd5882b 100644 --- a/js/debug.js +++ b/js/debug.js @@ -1,5 +1,15 @@ -$().ready(function() +var poll = function (url_prefix) { + setTimeout(function(){ + $.get(url_prefix+"/status_debug").done(function(response){ + $("#status").text(response); + poll(url_prefix); + }); + }, 3000); +} + +$().ready(function() { + // send commands using ajax $(".ajax").each(function(x) { $(this).click(function() { @@ -10,15 +20,19 @@ $().ready(function() }) $("#features").click(function() { if (this.value=="Feature") this.value = ""; }); $("#features").focusout(function() { if (this.value == "") this.value = "Feature"; }); + $("#features_get").click(function() { if (this.value=="Feature") this.value = ""; }); + $("#features_get").focusout(function() { if (this.value == "") this.value = "Feature"; }); $("#features_value").click(function() { this.value = ""; }); $("#features_value").focusout(function() { if (this.value == "") this.value = "1e-05"; }); + $("#features_value_get").click(function() { this.value = ""; }); + $("#features_value_get").focusout(function() { if (this.value == "") this.value = "1e-05"; }); $("#feature_groups_value").click(function() { this.value = ""; }); $("#feature_groups_value").focusout(function() { if (this.value == "") this.value = "1e-05"; }); // set all sorts of learning rates $("#set_features").click(function() { k = $("#features").val(); v = $("#features_value").val(); - if (k=="Feature" || k=="" || v=="" || !parseFloat(v)) { + if (k=="Feature" || k=="" || v=="" || isNaN(parseFloat(v))) { alert("Malformed request."); } else { url_prefix = $("#features_type").val(); @@ -73,5 +87,27 @@ $().ready(function() $('') ); $("#original_svg").width($("#original_svg").children()[0].getBBox().width+"px"); + + // mark stale content + if ($("#up_val").text() != "true") { + $(".updated").each(function(i,el){$(el).addClass("stale")}) + } + + poll("http://"+document.URL.split("/")[2]); + + $("#get_features").click(function () { + $.get("http://"+document.URL.split("/")[2]+$("#features_type_get").val()+"/"+$("#features_get").val(), + function (data) { + $("#features_value_get").val(data); + }); + }); + + $("#get_feature_groups").click(function () { + $.get("http://"+document.URL.split("/")[2]+"/get_rate/"+$("#feature_groups_get").val(), + function (data) { + $("#feature_groups_value_get").val(data); + }); + }); + }); diff --git a/js/interface.js b/js/interface.js index 781dfde..3341575 100644 --- a/js/interface.js +++ b/js/interface.js @@ -1,5 +1,5 @@ /* - * (common) global vars + * Global vars * */ var data, // global data object @@ -244,7 +244,7 @@ var next = function () send_data["original_svg"] = document.getElementById("original_svg").value; } else { post_edit = $.trim(target_textarea.value); - send_data["post_edit"] = post_edit; + send_data["post_edit"] = encodeURIComponent(post_edit); send_data['type'] = 't'; } 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 diff --git a/static/debug.css b/static/debug.css index d24fb5b..ff66a7c 100644 --- a/static/debug.css +++ b/static/debug.css @@ -14,13 +14,14 @@ td.right { text-align:right } .black { color:#000 } .red { color:red } .green { color:green } -.small { font-size:.8em } -.tiny { font-size:.6em!important } +.small { font-size:.9em } +.tiny { font-size:.8em!important } .big { font-size:1.1em } .mono { font-family:monospace } .even { background:#fff } .odd { background: #ffffe0 } .up { text-align:right;margin-right:1em } +.stale { opacity:.125 } #svg_b64,#original_svg_b64 { display:none } #floater { float:right; diff --git a/views/debug.haml b/views/debug.haml index 0bf56ce..4ebb0a0 100644 --- a/views/debug.haml +++ b/views/debug.haml @@ -2,7 +2,7 @@ !!! %html %head - %title Debug view (Session ##{session_key}) + %title Debug view (Session #{session_key}) %link(rel="stylesheet" type="text/css" href="debug.css") %script{:src => "http://postedit.cl.uni-heidelberg.de/js/jquery.min.js"} %script{:src => "http://postedit.cl.uni-heidelberg.de/js/jquery.tablesorter.min.js"} @@ -25,7 +25,10 @@ %li %a{ :href => "#kbest" } K-best - %p.tiny Session: ##{session_key} + %p + Status: + %span#status ... + %p.tiny Session: #{session_key} /=######################################################################### %h2#controls Controls @@ -44,23 +47,42 @@ %a.ajax{:tgt => "/reset_extractor", :href => "#controls"} Reset extractor %li %a.ajax{:tgt => "/reset_new_rules", :href => "#controls"} Reset new rules - %li - %a.ajax{:tgt => "/shutdown", :href => "#controls"} Initiate shutdown + / + %li + %a.ajax{:tgt => "/shutdown", :href => "#controls"} Initiate shutdown %h3 Learning rates & weights - %p Set default weight or rate for specific features: + %p Get current weight/rate for specific features: + %input#features_get{ :value => "Feature", :style => "text-align:center; width:20em" } + %select#features_type_get + %option{ :value => "/get_weight" } Weight + %option{ :value => "/get_rate" } Rate + %input#features_value_get{ :value => " ", :style => "text-align:right; width:10em" } + %button#get_features + Get + %p Set weight/rate for specific features: + %input#features{ :value => "Feature", :style => "text-align:center; width:20em" } %select#features_type %option{ :value => "/set_weights" } Weight %option{ :value => "/set_learning_rates" } Rate - %input#features{ :value => "Feature", :style => "text-align:center; width:20em" } - %input#features_value{ :value => "1e-05", :style => "text-align:right; width:5em" } + %input#features_value{ :value => "1e-05", :style => "text-align:right; width:10em" } %button#set_features Set - %p Set rate for feature groups: + %p + Set rate for feature groups: + %span.tiny (Features unseen in training/tuning have a common default rate.) + %select#feature_groups_get + %option{ :value => "R" } rule ids + %option{ :value => "RB" } rule bigrams + %option{ :value => "Shape" } rule shapes + %input#feature_groups_value_get{ :value => "1e-05", :style => "text-align:right; width:10em" } + %button#get_feature_groups + Get rate + %br %select#feature_groups %option{ :value => "R" } rule ids %option{ :value => "RB" } rule bigrams %option{ :value => "Shape" } rule shapes - %input#feature_groups_value{ :value => "1e-05", :style => "text-align:right; width:5em" } + %input#feature_groups_value{ :value => "1e-05", :style => "text-align:right; width:10em" } %button#set_feature_groups Set rate @@ -81,7 +103,7 @@ %tr %td.noborder %strong Progress: - %td.left.noborder #{[0,progress].max} + %td.left.noborder ##{[0,progress].max} %tr %td.noborder %strong MT Input: @@ -109,14 +131,16 @@ %tr %td.noborder %strong Best match (BLEU=#{(pairwise_ranking_data["best_match_score"]*100).round(2)}%): - %td.left.noborder #{pairwise_ranking_data["best_match"]} + %td.left.noborder.updated #{pairwise_ranking_data["best_match"]} %h3 Metadata - %p K: #{pairwise_ranking_data["samples_size"]} - %p Number of updates: #{pairwise_ranking_data["num_up"]} - %p Updated features: #{pairwise_ranking_data["updated_features"]} - %p Duration: #{data["durations"][progress]}ms - %p Updated: #{data["updated"][progress]} + %p + Updated: + %span#up_val #{data["updated"][progress]} + %p.updated K: #{pairwise_ranking_data["samples_size"]} + %p.updated Number of updates: #{pairwise_ranking_data["num_up"]} + %p.updated Updated features: #{pairwise_ranking_data["updated_features"]} + %p Duration: #{data["durations"][progress]}ms %h3 Derivation %p @@ -138,6 +162,8 @@ /=######################################################################### %h2#grammar Grammar + %p Notes: In addition to dynamically adding each source/post-edit instance to the suffix array extractor, the system additionally uses the provided phrase alignments to extract new rules. The extraction follows the original Hiero grammar extraction, but using phrases instead of words and using only a single binary feature: 'NewRule=1'. Extracted rules that already exist in a grammar are annotated with an additional feature: 'KnownRules=1'. OOVs are avoided by asking the user for translations of unknown words prior to translation. These are added to the grammars as new rules ('OOVFix=1'). + %h3 New Rules %p Including OOV fixes. @@ -175,11 +201,13 @@ /=######################################################################### %h2#weights Weights - %p N.B. that updates are only done if the post-edit is different from the original 1-best output of the decoder. + %p Notes: If the user modifies the string of the original one-best output, a standard pairwise ranking update is made, using the post-edit as reference translation. No update is performed if the string is not modified. The k-best list is not modified, as the original grammar is used (leave-one-out). + / + %p N.B. that updates are only done if the post-edit is different from the original 1-best output of the decoder. %p Update of a single row is: After = Before - (Rate * -Raw Diff.) = Before + (Rate * Raw. Diff.). The 'Raw Diff.' column is the sum of the difference vectors of the misranked pairs. %h3 Weight updates - %table.sortable + %table.sortable.updated %thead %tr %th Feature @@ -218,8 +246,8 @@ ERROR: unknown key #{k} %p - %a{ :onclick => "$('#features').toggle()" } Explanations - %table#features{ :style => "display:none" } + %a{ :onclick => "$('#features_expl').toggle()" } Explanations + %table#features_expl{ :style => "display:none" } %tr %td EgivenFCoherent %td.left -log10[ c(e, f) / sample c(f) ] @@ -273,7 +301,7 @@ %td.left Indicator features for rule shapes (39 in total) %tr %td IsSupportedOnline - %td.left Rules with support from local context (Denkowski) + %td.left Rules with support from local context (added by Denkowski's online suffix array extractor) %p.up %a{ :href => "#" } ^ up @@ -281,9 +309,10 @@ /=######################################################################### %h2#kbest K-best list %p + Notes: %span.red In red: - %span Update needed, i.e. "any of the above hypotheses has a lower model score" (in default order). - %table.sortable + %span Update needed, i.e. "any of the above hypotheses has a lower model score" (if the list is ordered by BLEU score in descending order). + %table.sortable.updated %thead %tr %th.center{:style => "width:5%"} Rank -- cgit v1.2.3