From 96d954177a95fe69ebebf8ebdbab63434bf4c600 Mon Sep 17 00:00:00 2001 From: Patrick Simianer Date: Tue, 3 May 2016 12:59:19 +0200 Subject: not using online grammar extractor --- views/debug.haml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/views/debug.haml b/views/debug.haml index 4ebb0a0..1bc0fd1 100644 --- a/views/debug.haml +++ b/views/debug.haml @@ -43,10 +43,13 @@ %a.ajax{:tgt => "/reset_weights", :href => "#controls"} Reset weights %li %a.ajax{:tgt => "/reset_learning_rates", :href => "#controls"} Reset learning rates + / + %li + %a.ajax{:tgt => "/reset_extractor", :href => "#controls"} Reset extractor %li - %a.ajax{:tgt => "/reset_extractor", :href => "#controls"} Reset extractor + %a.ajax{:tgt => "/reset_grammars", :href => "#controls"} Reset grammars %li - %a.ajax{:tgt => "/reset_new_rules", :href => "#controls"} Reset new rules + %a.ajax{:tgt => "/reset_new_rules", :href => "#controls"} Reset new rules / %li %a.ajax{:tgt => "/shutdown", :href => "#controls"} Initiate shutdown @@ -299,9 +302,9 @@ %tr %td Shape_* %td.left Indicator features for rule shapes (39 in total) - %tr - %td IsSupportedOnline - %td.left Rules with support from local context (added by Denkowski's online suffix array extractor) + /=%tr + /= %td IsSupportedOnline + /= %td.left Rules with support from local context (added by Denkowski's online suffix array extractor) %p.up %a{ :href => "#" } ^ up -- cgit v1.2.3 From 54bc620c309d471989824d5de50915728b2f3afc Mon Sep 17 00:00:00 2001 From: Patrick Simianer Date: Tue, 3 May 2016 14:22:07 +0200 Subject: mv --- .htaccess | 2 +- README.md | 25 ++++++++++++++++++++----- external/lfpe-apache | 8 ++++---- inc/db.inc.php | 2 +- js/interface.js | 5 +++-- static/pattr-abstracts.html | 10 +++++----- util/run_server | 22 ++++++++++++---------- 7 files changed, 46 insertions(+), 28 deletions(-) diff --git a/.htaccess b/.htaccess index a2cb1b7..cf61c47 100644 --- a/.htaccess +++ b/.htaccess @@ -1,5 +1,5 @@ AuthName "Post-Editing Interface" AuthType Basic -AuthUserFile /fast_scratch/simianer/lfpe/.htpasswd +AuthUserFile /srv/postedit/.htpasswd require valid-user diff --git a/README.md b/README.md index 403d745..a3d4e96 100644 --- a/README.md +++ b/README.md @@ -2,20 +2,35 @@ Post-editing interface for learning from post-edited machine translations. # Setup + +` + export BASE_DIR=/srv/postedit +` + ## nanomsg lib - export LD_LIBRARY_PATH=/fast_scratch/simianer/lfpe/lib/nanomsg-0.5-beta/lib +` + export LD_LIBRARY_PATH=$BASE_DIR/lib/nanomsg-0.5-beta/lib +` ## ruby - [see $(pwd)/lib/ruby/gems/nanomsg-0.4.0/ext/extconf.rb] - gem install nanomsg -i $(pwd)/lib/ruby - export GEM_PATH=/fast_scratch/simianer/lfpe/lib/ruby/:$GEM_PATH +` + [see $BASE_DIR/lib/ruby/gems/nanomsg-0.4.0/ext/extconf.rb] + gem install nanomsg -i $BSAE_DIR/lib/ruby + export GEM_PATH=$BASE_DIR/lib/ruby/:$GEM_PATH +` ## iptables +` iptables -A INPUT -i eth0 -p tcp -m multiport --dports 50000:50100 -j ACCEPT +` ## apache +` ln -s /etc/apache2/sites-available/lfpe /etc/apache2/sites-enabled/020-lfpe +` ## python - export PYTHONPATH=/fast_scratch/simianer/lfpe/lib/python:$PYTHONPATH +` + export PYTHONPATH=$BASE_DIR/lib/python:$PYTHONPATH +` diff --git a/external/lfpe-apache b/external/lfpe-apache index e4de4be..eec5e5c 100644 --- a/external/lfpe-apache +++ b/external/lfpe-apache @@ -3,13 +3,13 @@ ServerAdmin simianer@cl.uni-heidelberg.de - DocumentRoot /fast_scratch/simianer/lfpe/lfpe + DocumentRoot /srv/postedit/lfpe - ErrorLog /fast_scratch/simianer/lfpe/lfpe/logs/apache2.error.log + ErrorLog /srv/postedit/lfpe/logs/apache2.error.log LogLevel warn - CustomLog /fast_scratch/simianer/lfpe/lfpe/logs/apache2.access.log combined + CustomLog /srv/postedit/lfpe/logs/apache2.access.log combined - + Options +FollowSymLinks AllowOverride All order allow,deny diff --git a/inc/db.inc.php b/inc/db.inc.php index f08eda5..ed45f7b 100644 --- a/inc/db.inc.php +++ b/inc/db.inc.php @@ -1,6 +1,6 @@ Abstracts -

EP-0005734-A1 (H01H)

+

EP-0005734-A1 (H01H)

Ein elektromagnetisch betätigtes Schaltgerät, z. B. ein elektrisches Schütz, hat einen magnetischen Eisenkern, der aus zwei gleichen E-förmigen Magnetteilen besteht, nämlich dem die Wicklung tragenden Magnetkern (8) und dem Anker (7).

An electromagnetically operated switchgear, e.g. an electrical contactor, has a magnetic iron core which consists of two identical E- shaped magnet parts, specifically the magnet core (8), carrying the winding, and the armature (7). @@ -38,7 +38,7 @@ div.ex:hover {
-

EP-0003301-A1 (A01N,C07C)

+

EP-0003301-A1 (A01N,C07C)

Sie weisen starke insektizide, akarizide und nematizide Eigenschaften auf.

They have strong insecticidal, acaricidal and nematicidal properties. @@ -50,7 +50,7 @@ div.ex:hover {
-

EP-0003578-A2 (F25B)

+

EP-0003578-A2 (F25B)

Die Erfindung bezieht sich auf den Kältemittelkreislauf (1) einer Wärmepumpe.

The invention relates to the refrigerant circuit (1) of a heat pump. @@ -78,7 +78,7 @@ div.ex:hover {
-

EP-0002017-A1 (C25B)

+

EP-0002017-A1 (C25B)

Anoden für Elektrolysezwecke bestehen aus einem elektrisch leitenden Trägerkörper und einer darauf aufgebrachten Schicht aus metallischem Silicium und/oder Germanium.

Anodes for electrochemical purposes are composed of an electrically conducting support body and a layer of metallic silicon and/or germanium applied thereto. @@ -94,7 +94,7 @@ div.ex:hover {
-

EP-0018427-A1 (G05B)

+

EP-0018427-A1 (G05B)

Elektrische Steuerschaltung mit einem Signalgenerator­ teil (20), der in Abhängigkeit von einem Führungssignal auf­ einanderfolgende gleichmäßige Impulse erzeugt.

Electrical control circuit comprising a signal generator section (20) which generates successive uniform pulses in dependence on a control signal. diff --git a/util/run_server b/util/run_server index 7d45583..a4b7a6c 100755 --- a/util/run_server +++ b/util/run_server @@ -1,15 +1,17 @@ #!/bin/bash -x -export LD_LIBRARY_PATH=/fast_scratch/simianer/lfpe/lib/nanomsg-0.5-beta/lib:$LD_LIBRARY_PATH -export PYTHONPATH=/fast_scratch/simianer/lfpe/lib/python:$PYTHONPATH -export GEM_PATH=/fast_scratch/simianer/lfpe/lib/ruby/:$GEM_PATH -UTIL=/fast_scratch/simianer/lfpe/lfpe/util +BASE_DIR=/srv/postedit +export LD_LIBRARY_PATH=$BASE_DIR/lib/nanomsg-0.5-beta/lib:$LD_LIBRARY_PATH +export PYTHONPATH=$BASE_DIR/lib/python:$PYTHONPATH +export GEM_PATH=$BASE_DIR/lib/ruby/:$GEM_PATH +UTIL=$BASE_DIR/lfpe/util SESSION=$1 -DIR=/fast_scratch/simianer/lfpe/sessions/$SESSION +SESSION_DIR=$BASE_DIR/sessions/$SESSION -rm $DIR/work/lockfile -rm -r $DIR/work/ -mkdir -p $DIR/work -cp $DIR/data.json.original $DIR/data.json -$UTIL/../server.rb $DIR/conf.rb &>$DIR/work/session.out +rm $SESSION_DIR/work/lockfile +rm -r $SESSION_DIR/work/ +mkdir -p $SESSION_DIR/work +cp $SESSION_DIR/data.json.original $SESSION_DIR/data.json +cp $SESSION_DIR/g/original/* $SESSION_DIR/g/ +$UTIL/../server.rb $SESSION_DIR/conf.rb &>$SESSION_DIR/work/session.out -- cgit v1.2.3 From b74ed595f149986474931f9328f84348a5652730 Mon Sep 17 00:00:00 2001 From: Patrick Simianer Date: Tue, 3 May 2016 14:22:20 +0200 Subject: parameters --- phrase2_extraction/phrase2_extraction.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/phrase2_extraction/phrase2_extraction.rb b/phrase2_extraction/phrase2_extraction.rb index 48dfd73..253df1b 100755 --- a/phrase2_extraction/phrase2_extraction.rb +++ b/phrase2_extraction/phrase2_extraction.rb @@ -5,9 +5,9 @@ require 'zipf' module PhrasePhraseExtraction DEBUG = false -MAX_NT = 2 # Chiang: 2 -MAX_SEED_NUM_WORDS = 3 # Chiang: 10 words -MAX_SRC_SZ = 3 # Chiang: 5 words +MAX_NT = 1 # Chiang: 2 +MAX_SEED_NUM_WORDS = 10 # Chiang: 10 words +MAX_SRC_SZ = 5 # Chiang: 5 words FORBID_SRC_ADJACENT_SRC_NT = true # Chiang:true class Rule -- cgit v1.2.3 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 From 96d6f8a3fc83e075f8054d48ea8c6973ca534b65 Mon Sep 17 00:00:00 2001 From: Patrick Simianer Date: Fri, 6 May 2016 11:14:48 +0200 Subject: fix --- util/run_beta_test | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/util/run_beta_test b/util/run_beta_test index a0fe20f..9180b52 100755 --- a/util/run_beta_test +++ b/util/run_beta_test @@ -1,8 +1,8 @@ #!/bin/zsh -x -cd /fast_scratch/simianer/lfpe/lfpe/util +cd /srv/postedit/lfpe/util ./kill; ./kill; ./kill; -for i in ../../sessions/product_de-en_beta_test_*; do +for i in `ls -1 ../../sessions/ | grep -v "_1_" | grep -v data | grep -v toy`; do echo $i echo $(basename $i) ./run_server $(basename $i) &; sleep 600; -- cgit v1.2.3 From 6bd7135e6039b0682f49234e42451077413f0bd9 Mon Sep 17 00:00:00 2001 From: Patrick Simianer Date: Tue, 10 May 2016 10:49:09 +0200 Subject: count clicks and keystrokes, fix bug in rule addition, good params and improvement for phrase2 extraction --- interface.php | 5 ++-- js/interface.js | 47 +++++++++++++++++++++++++++++++- phrase2_extraction/phrase2_extraction.rb | 38 +++++++++++++++++++++++--- server.rb | 10 ++++--- views/debug.haml | 2 ++ 5 files changed, 91 insertions(+), 11 deletions(-) diff --git a/interface.php b/interface.php index 8df7fd0..46b07f0 100644 --- a/interface.php +++ b/interface.php @@ -33,7 +33,7 @@ Target: - + @@ -52,7 +52,7 @@ Note that the source word may be distorted.
- + Working: ...
@@ -103,5 +103,6 @@ Note that the source word may be distorted. + diff --git a/js/interface.js b/js/interface.js index d346b96..f009641 100644 --- a/js/interface.js +++ b/js/interface.js @@ -5,6 +5,9 @@ var data, // global data object ui_type; // 't' (text) or 'g' (graphical) +var TEXT_count_click=0, + TEXT_count_kbd=0; + /* * cross-site request * @@ -108,6 +111,18 @@ var catch_return = function (e) return false; } +var TEXT_handle_keypress = function (e) +{ + if (e.keyCode == 13) { + e.preventDefault(); + next(); + } + + TEXT_count_kbd += 1; + + return false; +} + /* * working/not working * @@ -259,6 +274,8 @@ var next = function () post_edit = $.trim(target_textarea.value); send_data["post_edit"] = encodeURIComponent(post_edit); send_data['type'] = 't'; + send_data["count_click"] = TEXT_count_click; + send_data["count_kbd"] = TEXT_count_kbd; } send_data["key"] = key; @@ -456,8 +473,11 @@ var request_and_process_next = function () target_textarea.rows = Math.round(translation.length/80+0.5); //raw_source_textarea.rows = Math.round(raw_source.length/80+0.5); target_textarea.focus(); + $("#original_mt").val(target_textarea.value); target_textarea.selectionStart = 0; target_textarea.selectionEnd = 0; + TEXT_count_click = 0; + TEXT_count_kbd = 0; // remember aux data in DOM current_seg_id.value = id; @@ -493,10 +513,35 @@ var init_text_editor = function () { document.getElementById("target_textarea").value = ""; document.getElementById("target_textarea").setAttribute("disabled", "disabled"); + + TEXT_count_click = 0; + TEXT_count_kbd = 0; + + $("#target_textarea").click(function () { + TEXT_count_click += 1; + }); return false; } +var get_ui_type = function () +{ + return document.getElementById("ui_type").value; +} + +var reset = function () +{ + var ui_type = get_ui_type(); + if (ui_type == "t") { + if (!$("#init").val()) return; + TEXT_count_click = 0; + TEXT_count_kbd = 0; + $("#target_textarea").val($("#original_mt").val()); + } else if (ui_type == "g") { + DE_init() + } +} + /* * init site * @@ -514,7 +559,7 @@ $().ready(function() not_working(); - ui_type = document.getElementById("ui_type").value; + ui_type = get_ui_type(); // graphical derivation editor if (ui_type == "g") { diff --git a/phrase2_extraction/phrase2_extraction.rb b/phrase2_extraction/phrase2_extraction.rb index 253df1b..547e0be 100755 --- a/phrase2_extraction/phrase2_extraction.rb +++ b/phrase2_extraction/phrase2_extraction.rb @@ -5,9 +5,9 @@ require 'zipf' module PhrasePhraseExtraction DEBUG = false -MAX_NT = 1 # Chiang: 2 -MAX_SEED_NUM_WORDS = 10 # Chiang: 10 words -MAX_SRC_SZ = 5 # Chiang: 5 words +MAX_NT = 2 # Chiang: 2 +MAX_SEED_NUM_WORDS = 4 # Chiang: 10 words, -> phrases! +MAX_SRC_SZ = 10 # Chiang: 5 words, -> words! FORBID_SRC_ADJACENT_SRC_NT = true # Chiang:true class Rule @@ -51,6 +51,21 @@ class Rule return src_len end + def len_src_w + src_len = 0 + @source.each { |i| + if i.is_a? String + src_len += i.split.size #1 + else + i.each { |j| + src_len += source_context[j].split.size + } + end + } + + return src_len + end + def len_tgt tgt_len = 0 @target.each { |i| @@ -64,6 +79,21 @@ class Rule return tgt_len end + def len_tgt_w + tgt_len = 0 + @target.each { |i| + if i.is_a? String + tgt_len += i.split.size + else + i.each { |j| + tgt_len += target_context[j].split.size + } + end + } + + return tgt_len + end + def to_s source_string = "" @source.each { |i| @@ -625,7 +655,7 @@ end def PhrasePhraseExtraction.remove_too_long_src_sides rules return rules.reject { |r| - r.len_src > PhrasePhraseExtraction::MAX_SRC_SZ + r.len_src_w > PhrasePhraseExtraction::MAX_SRC_SZ } end diff --git a/server.rb b/server.rb index 9ca43b1..599fdbd 100755 --- a/server.rb +++ b/server.rb @@ -295,6 +295,8 @@ def process_next reply $db['svg'] << data['svg'] $db['original_svg'] << data['original_svg'] $db['durations'] << data['duration'].to_f + $db['count_click'] << data['count_click'].to_i + $db['count_kbd'] << data['count_kbd'].to_i $db['post_edits_display'] << send_recv(:detokenizer, post_edit) $last_processed_postedit = $db['post_edits_display'].last # 1. tokenize @@ -423,13 +425,13 @@ def process_next reply all_rules[j] = ar end } - WriteFile.new(grammar).write all_rules.join("\n")+"\n" # - additional rules - logmsg :server, $new_rules.to_s + #logmsg :server, $new_rules.to_s if $new_rules.size > 0 - s = $new_rules.join "\n" - `echo "#{s}" >> #{grammar}` + all_rules += $new_rules + #`echo "#{s}" >> #{grammar}` end + WriteFile.new(grammar).write all_rules.join("\n")+"\n" #$new_rules.each { |rule| # logmsg :server, "adding rule '#{rule}' to grammar '#{grammar}'" # s = splitpipe(rule)[1..2].map{|i|i.strip.lstrip}.join(" ||| ") diff --git a/views/debug.haml b/views/debug.haml index 1bc0fd1..3c1e006 100644 --- a/views/debug.haml +++ b/views/debug.haml @@ -144,6 +144,8 @@ %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 + %p Keypresses: #{data["count_kbd"][progress]} + %p Clicks: #{data["count_click"][progress]} %h3 Derivation %p -- cgit v1.2.3