summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Simianer <p@simianer.de>2016-06-14 14:27:45 +0200
committerPatrick Simianer <p@simianer.de>2016-06-14 14:27:45 +0200
commitabcae4f39145863b4861588f885991b6dac662aa (patch)
tree18249899164ecc4ffbe51653b11551c06d304258
parent9df3b86e6a5b087d441c161c03a6fb3298943864 (diff)
parent1a51b3797d4c3a846e47b105a5edcb8283726651 (diff)
Merge branch 'master' of github.com:pks/lfpe
-rw-r--r--inc/db.inc.php5
-rw-r--r--inc/help.inc.php5
-rw-r--r--index.php60
-rw-r--r--interface.php3
-rw-r--r--js/interface.js13
-rw-r--r--pool.php6
-rwxr-xr-xserver.rb6
-rw-r--r--static/main.css4
-rwxr-xr-xutil/run_all4
-rw-r--r--views/summary.haml4
10 files changed, 78 insertions, 32 deletions
diff --git a/inc/db.inc.php b/inc/db.inc.php
index ed45f7b..e023c3a 100644
--- a/inc/db.inc.php
+++ b/inc/db.inc.php
@@ -1,7 +1,10 @@
<?php
$SESSION_DIR="/srv/postedit/sessions";
-$json = file_get_contents($SESSION_DIR."/".$_GET["key"]."/data.json");
+$key = $_GET["key"];
+if (preg_match('/^[a-z0-9]{1,4}$/', $key)) {
+ $json = file_get_contents($SESSION_DIR."/".$key."/data.json");
+}
$db = json_decode($json);
?>
diff --git a/inc/help.inc.php b/inc/help.inc.php
index c29d989..86ddf70 100644
--- a/inc/help.inc.php
+++ b/inc/help.inc.php
@@ -1,5 +1,6 @@
-<p>Press the 'Next' button to <strong>submit</strong> your post-edit and to request the next segment for post-edition.
-In the textual interface, you may just press return when the post-edit is finished (and 'Target' text area is in focus).</p>
+<p>Press the 'Next' button to <strong>submit</strong> your translation or post-edit and to request the next segment for post-edition.
+<!--In the textual interface, you may just press return when the post-edit is finished (and 'Target' text area is in focus).-->
+</p>
<p>The session can be paused at any time and continued later -- just press 'Pause'. Note that we are collecting timing information, so pausing your session on inactivity is important for us. You may also just reload this site upon your return and re-request the segment to reset the timer.</p>
diff --git a/index.php b/index.php
index 4aed520..4b7e13c 100644
--- a/index.php
+++ b/index.php
@@ -3,6 +3,15 @@
<meta charset="utf-8" />
<title>Post-Editing Interface</title>
<script src="js/jquery.min.js" charset="utf-8"></script>
+ <script type="text/javascript">
+ var check_submit = function () {
+ if ($("#name").val()=="" || $("#key").val()=="") {
+ alert("Please enter a session key and a name.")
+ return;
+ }
+ document.sess.submit();
+ }
+ </script>
<link rel="stylesheet" type="text/css" href="static/main.css" />
</head>
@@ -10,23 +19,49 @@
<?php include("inc/header.inc.php"); ?>
-<form method="get" action="interface.php">
- <strong>Please enter your session key:</strong>
- <input type="text" id="key" name="key" style="width:20em" />
- &nbsp;&nbsp;&nbsp;&nbsp;Session type:
+<form method="get" name="sess" action="interface.php">
+ <strong>Session key:</strong>
+ <input type="text" id="key" name="key" style="width:8em" />
+ &nbsp;&nbsp;&nbsp;&nbsp;<strong>Name:</strong>
+ <input type="txt" id="name" name="name" style="width:12em" />
+ &nbsp;&nbsp;&nbsp;&nbsp;<strong>Session type:</strong>
<select name="ui_type">
- <option value="g">graphical</option>
<option value="t">text</option>
+ <option value="g">graphical</option>
</select>
&nbsp;&nbsp;&nbsp;
-<input type="submit" value="Submit" />
+<input type="button" value="Submit" onclick="check_submit()" />
</form>
<!--<div class="small" style="background:#eee;margin: 5em 0 5em 0;padding:.5em; max-width:25%">
-<p>Select:
-<select class="small">
- <option value="g0_0_nomt" onclick="document.getElementById('key').value=this.value;">#0 (from scratch)</option>
+
+<?php
+//if ($_GET['manual']) {
+echo "<p>Select session: ";
+echo "<select class='small'>";
+
+ $f = fopen("../sessions/sessions", "r");
+ $a = array();
+ while (($line = fgets($f)) !== false) {
+ $x = explode("\t", $line, 4);
+ $a[$x[3]] = $x[0];
+ }
+ fclose($f);
+
+ asort($a);
+
+ foreach ($a as $key => $val) {
+ echo "<option value='".$val."' onclick=\"document.getElementById('key').value=this.value;\">Session ".$key."</option>";
+ }
+ echo "</select></p>";
+//} else {
+// echo '<p style="padding:1em"><a style="font-size:1.2em;color:#000" href="pool.php">Assignment</a></p><p><a href="?manual=1">Manual</a>';
+//}
+?>
+-->
+
+<!-- <option value="g0_0_nomt" >#0 (from scratch)</option>
<option value="g0_0_pe" onclick="document.getElementById('key').value=this.value;">#0 (post-editing)</option>
<optgroup label="________________"></optgroup>
<option value="g0_1_nomt" onclick="document.getElementById('key').value=this.value;">#1 (from scratch)</option>
@@ -133,11 +168,10 @@
<option value="product_en-de_beta_test_1_D" onclick="document.getElementById('key').value=this.value;">D* en-de</option>
</optgroup>-->
-<!--</select>
-</p>
-</div>-->
-<a style="font-size:1.2em;color:#000" href="pool.php">Assignment</a>
+
+</div>
+
<?php include("inc/footer.inc.php"); ?>
diff --git a/interface.php b/interface.php
index 5ea96ae..00d8779 100644
--- a/interface.php
+++ b/interface.php
@@ -49,7 +49,7 @@ Note that the source word may be distorted.
<!-- /Source and target textboxes -->
<!-- Summary -->
-<div id="view_summary" style="display:none;margin:2em"><strong>Session finished, thank you!</strong> View <a href="http://postedit.cl.uni-heidelberg.de:<?php echo $db->port; ?>/summary" target="_blank">summary</a>.</div>
+<div id="view_summary" style="display:none;margin:2em"><strong>Session finished, thank you!</strong> View <a href="http://postedit.cl.uni-heidelberg.de:<?php echo $db->port; ?>/summary" target="_blank">Summary</a>.</div>
<!-- /Summary -->
<!-- Buttons -->
@@ -109,5 +109,6 @@ Note that the source word may be distorted.
<textarea style="display:none" id="data" ></textarea>
<textarea style="display:none" id="original_svg" ></textarea>
<textarea style="display:none" id="original_mt" ></textarea>
+<textarea style="display:none" id="name" ><?php echo $_GET["name"]; ?></textarea>
<!-- /Data -->
diff --git a/js/interface.js b/js/interface.js
index 4c9685d..b86bf50 100644
--- a/js/interface.js
+++ b/js/interface.js
@@ -105,7 +105,7 @@ var catch_return = function (e)
{
if (e.keyCode == 13) {
e.preventDefault();
- next();
+ //next();
}
return false;
@@ -115,7 +115,7 @@ var TEXT_handle_keypress = function (e)
{
if (e.keyCode == 13) {
e.preventDefault();
- next();
+ //next();
}
TEXT_count_kbd += 1;
@@ -286,6 +286,7 @@ var next = function ()
}
send_data["key"] = key;
+ send_data["name"] = $("#name").val();
// send data
if (oov_correct.value=="false" && post_edit != "") {
@@ -398,7 +399,7 @@ var request_and_process_next = function ()
if (data["fin"]) {
target_textarea.setAttribute("disabled", "disabled");
status.style.display = "none";
- button.innerHTML = "---";
+ //button.innerHTML = "-----";
$("#view_summary").toggle()
$("#raw_source_textarea").html("");
$("#target_textarea").val("");
@@ -542,11 +543,11 @@ 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;
+ //TEXT_count_click = 0;
+ //TEXT_count_kbd = 0;
$("#target_textarea").val($("#original_mt").val());
} else if (ui_type == "g") {
- DE_init()
+ DE_init(false)
}
}
diff --git a/pool.php b/pool.php
index ad8de29..bce819c 100644
--- a/pool.php
+++ b/pool.php
@@ -11,7 +11,7 @@
</head>
<body>
- <p style='margin:2em;color:#000'><strong>Click on a table cell, enter your name, and click 'Begin' to begin your session. Reload the page if you clicked on the wrong cell.</strong></p>
+ <p style='margin:2em;color:#000'><strong>Click on a table cell, enter your name, and click 'Begin' to begin your session. Reload the page if you clicked on the wrong cell or if the session is already used by someone else.</strong></p>
<table border=1 style="margin-left:10%">
<tr><td>#0</td></tr>
</table>
@@ -41,8 +41,8 @@
$max = $j;
}
}
- fclose($f);
-
+ fclose($f);
+
for ($i=1; $i<=$max; $i++) {
echo "<td class='item' session='".$b[$i]."' id='item".$i."'>#".$i."<br /><span style='font-size:.5em'>".$b[$i]."</span></td>\n";
if ($i%5 == 0) {
diff --git a/server.rb b/server.rb
index e6bf258..d25e216 100755
--- a/server.rb
+++ b/server.rb
@@ -179,6 +179,10 @@ def process_next reply
return
end
$lock = true # lock
+ if !data['name'] || data['name'] == ""
+ $status = "Error: Name not given."
+ return
+ end
if data['key'] != SESSION_KEY
$status = "Error: Key mismatch (#{data['key']}, #{SESSION_KEY})"
return
@@ -721,7 +725,7 @@ get '/summary' do
g.write data["references"][j]+"\n"
f.close
g.close
- ter_scores << (`#{CDEC}/mteval/fast_score -i #{f.path} -r #{g.path} -m ter 2>/dev/null`.to_f).round(2)
+ ter_scores << [1.0, (`#{CDEC}/mteval/fast_score -i #{f.path} -r #{g.path} -m ter 2>/dev/null`.to_f).round(2)].min
f.unlink
g.unlink
}
diff --git a/static/main.css b/static/main.css
index 59f8870..49623fe 100644
--- a/static/main.css
+++ b/static/main.css
@@ -33,10 +33,10 @@ textarea, input {
.tiny { font-size:.6em }
a {
- color: #ddd;
+ color: #000;
text-decoration: underline
}
-a:hover { color: #000 }
+a:hover { color: #ccc; text-decoration: none }
div#wrapper {
margin: 2em;
diff --git a/util/run_all b/util/run_all
index 2fc511c..ef3386a 100755
--- a/util/run_all
+++ b/util/run_all
@@ -1,7 +1,9 @@
#!/bin/zsh -x
-for i in `find ../sessions -maxdepth 1 | cut -d "/" -f 3 | grep -P "^session_"`; do
+#for i in `find ../sessions -maxdepth 1 | cut -d "/" -f 3 | grep -P "^sess_"`; do
+for i in `cat ../sessions/sessions | cut -f 1`; do
echo $i
./util/run_server $i &
+ sleep 15
done
diff --git a/views/summary.haml b/views/summary.haml
index 29dc0ad..f5ff4b3 100644
--- a/views/summary.haml
+++ b/views/summary.haml
@@ -9,8 +9,8 @@
%script{:src => "http://postedit.cl.uni-heidelberg.de/js/debug.js"}
%body
%h1 Summary
- %p (Session #{session_key})
- %p Data is shown in the MT system's formatting. BLEU is calculated without smoothing.
+ %p.small (Session #{session_key})
+ %p Data is shown in the MT system's formatting. BLEU is calculated without smoothing. TER capped at 1.0.
%table
%tr
%td