Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDingyuan Wang <abcdoyle888@gmail.com>2015-04-11 04:26:25 +0300
committerDingyuan Wang <abcdoyle888@gmail.com>2015-04-11 04:26:25 +0300
commit4aba64ed53811daefd8250b59b8248cbe5e329da (patch)
tree731bed5cddb3f28ab769afb370c1a7754b1e13a5 /scripts
parentd6a66d39bd3631401c5977ae508e5c7a44e65359 (diff)
parentaea07b0a1992bf2765031fa96d946c241de9a586 (diff)
Merge pull request #106 from gumblex/master
Fix some problems in EMS
Diffstat (limited to 'scripts')
-rw-r--r--scripts/ems/web/analysis.php8
-rw-r--r--scripts/ems/web/base64.js285
-rw-r--r--scripts/ems/web/bilingual-concordance.css1
-rw-r--r--scripts/ems/web/index.php2
-rw-r--r--scripts/ems/web/javascripts/scriptaculous-js-1.8.3/README.rdoc6
-rw-r--r--scripts/ems/web/overview.php5
6 files changed, 196 insertions, 111 deletions
diff --git a/scripts/ems/web/analysis.php b/scripts/ems/web/analysis.php
index a64d5977f..00bb9e15f 100644
--- a/scripts/ems/web/analysis.php
+++ b/scripts/ems/web/analysis.php
@@ -1261,8 +1261,8 @@ function input_annotation($sentence,$input,$segmentation,$filter) {
for($j=$from;$j<=$to;$j++) {
if ($j>$from) { $phrase .= " "; }
$phrase .= $word[$j];
- $highlightwords .= " document.getElementById('inputword-$i-$j').style.backgroundColor='#ffff80';";
- $lowlightwords .= " document.getElementById('inputword-$i-$j').style.backgroundColor='".coverage_color($coverage[$j][$j])."';";
+ $highlightwords .= " document.getElementById('inputword-$sentence-$j').style.backgroundColor='#ffff80';";
+ $lowlightwords .= " document.getElementById('inputword-$sentence-$j').style.backgroundColor='".coverage_color($coverage[$j][$j])."';";
}
print "<td colspan=$size><div style=\"background-color: $color; height:3px;\" onmouseover=\"show_word_info($sentence,".$coverage[$from][$to]["corpus_count"].",".$coverage[$from][$to]["ttable_count"].",".$coverage[$from][$to]["ttable_entropy"]."); this.style.backgroundColor='#ffff80';$highlightwords\" onmouseout=\"hide_word_info($sentence); this.style.backgroundColor='$color';$lowlightwords;\"".($biconcor?" onclick=\"show_biconcor($sentence,'".base64_encode($phrase)."');\"":"").">";
}
@@ -1443,10 +1443,10 @@ function biconcor($query) {
$sentence = $_GET['sentence'];
$biconcor = get_biconcor_version($dir,$set,$id);
print "<center>
-<form method=get id=\"BiconcorForm\">
+<form method=\"get\" id=\"BiconcorForm\" onsubmit=\"return false;\">
<img src=\"close.gif\" width=17 height=17 onClick=\"close_biconcor($sentence);\">
<input width=20 id=\"BiconcorQuery\" value=\"$query\">
-<input type=submit onclick=\"show_biconcor($sentence,encodeBase64(document.getElementById('BiconcorQuery').value));\" value=\"look up\">
+<input type=submit onclick=\"show_biconcor($sentence,Base64.encode(document.getElementById('BiconcorQuery').value));\" value=\"look up\">
</form>
<div class=\"biconcor-content\">";
$cmd = "./biconcor -html -l $dir/model/biconcor.$biconcor -Q ".base64_encode($query)." 2>/dev/null";
diff --git a/scripts/ems/web/base64.js b/scripts/ems/web/base64.js
index e0e94d765..67fd9ad8d 100644
--- a/scripts/ems/web/base64.js
+++ b/scripts/ems/web/base64.js
@@ -1,108 +1,193 @@
-var END_OF_INPUT = -1;
+/*
+ * $Id: base64.js,v 2.15 2014/04/05 12:58:57 dankogai Exp dankogai $
+ *
+ * Licensed under the MIT license.
+ * http://opensource.org/licenses/mit-license
+ *
+ * References:
+ * http://en.wikipedia.org/wiki/Base64
+ */
-var base64Chars = new Array(
- 'A','B','C','D','E','F','G','H',
- 'I','J','K','L','M','N','O','P',
- 'Q','R','S','T','U','V','W','X',
- 'Y','Z','a','b','c','d','e','f',
- 'g','h','i','j','k','l','m','n',
- 'o','p','q','r','s','t','u','v',
- 'w','x','y','z','0','1','2','3',
- '4','5','6','7','8','9','+','/'
-);
-
-var reverseBase64Chars = new Array();
-for (var i=0; i < base64Chars.length; i++){
- reverseBase64Chars[base64Chars[i]] = i;
-}
-
-var base64Str;
-var base64Count;
-function setBase64Str(str){
- base64Str = str;
- base64Count = 0;
-}
-function readBase64(){
- if (!base64Str) return END_OF_INPUT;
- if (base64Count >= base64Str.length) return END_OF_INPUT;
- var c = base64Str.charCodeAt(base64Count) & 0xff;
- base64Count++;
- return c;
-}
-function encodeBase64(str){
- setBase64Str(str);
- var result = '';
- var inBuffer = new Array(3);
- var lineCount = 0;
- var done = false;
- while (!done && (inBuffer[0] = readBase64()) != END_OF_INPUT){
- inBuffer[1] = readBase64();
- inBuffer[2] = readBase64();
- result += (base64Chars[ inBuffer[0] >> 2 ]);
- if (inBuffer[1] != END_OF_INPUT){
- result += (base64Chars [(( inBuffer[0] << 4 ) & 0x30) | (inBuffer[1] >> 4) ]);
- if (inBuffer[2] != END_OF_INPUT){
- result += (base64Chars [((inBuffer[1] << 2) & 0x3c) | (inBuffer[2] >> 6) ]);
- result += (base64Chars [inBuffer[2] & 0x3F]);
- } else {
- result += (base64Chars [((inBuffer[1] << 2) & 0x3c)]);
- result += ('=');
- done = true;
- }
+(function(global) {
+ 'use strict';
+ // existing version for noConflict()
+ var _Base64 = global.Base64;
+ var version = "2.1.7";
+ // if node.js, we use Buffer
+ var buffer;
+ if (typeof module !== 'undefined' && module.exports) {
+ buffer = require('buffer').Buffer;
+ }
+ // constants
+ var b64chars
+ = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
+ var b64tab = function(bin) {
+ var t = {};
+ for (var i = 0, l = bin.length; i < l; i++) t[bin.charAt(i)] = i;
+ return t;
+ }(b64chars);
+ var fromCharCode = String.fromCharCode;
+ // encoder stuff
+ var cb_utob = function(c) {
+ if (c.length < 2) {
+ var cc = c.charCodeAt(0);
+ return cc < 0x80 ? c
+ : cc < 0x800 ? (fromCharCode(0xc0 | (cc >>> 6))
+ + fromCharCode(0x80 | (cc & 0x3f)))
+ : (fromCharCode(0xe0 | ((cc >>> 12) & 0x0f))
+ + fromCharCode(0x80 | ((cc >>> 6) & 0x3f))
+ + fromCharCode(0x80 | ( cc & 0x3f)));
} else {
- result += (base64Chars [(( inBuffer[0] << 4 ) & 0x30)]);
- result += ('=');
- result += ('=');
- done = true;
- }
- lineCount += 4;
- if (lineCount >= 76){
- result += ('\n');
- lineCount = 0;
+ var cc = 0x10000
+ + (c.charCodeAt(0) - 0xD800) * 0x400
+ + (c.charCodeAt(1) - 0xDC00);
+ return (fromCharCode(0xf0 | ((cc >>> 18) & 0x07))
+ + fromCharCode(0x80 | ((cc >>> 12) & 0x3f))
+ + fromCharCode(0x80 | ((cc >>> 6) & 0x3f))
+ + fromCharCode(0x80 | ( cc & 0x3f)));
}
+ };
+ var re_utob = /[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g;
+ var utob = function(u) {
+ return u.replace(re_utob, cb_utob);
+ };
+ var cb_encode = function(ccc) {
+ var padlen = [0, 2, 1][ccc.length % 3],
+ ord = ccc.charCodeAt(0) << 16
+ | ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8)
+ | ((ccc.length > 2 ? ccc.charCodeAt(2) : 0)),
+ chars = [
+ b64chars.charAt( ord >>> 18),
+ b64chars.charAt((ord >>> 12) & 63),
+ padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),
+ padlen >= 1 ? '=' : b64chars.charAt(ord & 63)
+ ];
+ return chars.join('');
+ };
+ var btoa = global.btoa ? function(b) {
+ return global.btoa(b);
+ } : function(b) {
+ return b.replace(/[\s\S]{1,3}/g, cb_encode);
+ };
+ var _encode = buffer ? function (u) {
+ return (u.constructor === buffer.constructor ? u : new buffer(u))
+ .toString('base64')
}
- return result;
-}
-function readReverseBase64(){
- if (!base64Str) return END_OF_INPUT;
- while (true){
- if (base64Count >= base64Str.length) return END_OF_INPUT;
- var nextCharacter = base64Str.charAt(base64Count);
- base64Count++;
- if (reverseBase64Chars[nextCharacter]){
- return reverseBase64Chars[nextCharacter];
+ : function (u) { return btoa(utob(u)) }
+ ;
+ var encode = function(u, urisafe) {
+ return !urisafe
+ ? _encode(String(u))
+ : _encode(String(u)).replace(/[+\/]/g, function(m0) {
+ return m0 == '+' ? '-' : '_';
+ }).replace(/=/g, '');
+ };
+ var encodeURI = function(u) { return encode(u, true) };
+ // decoder stuff
+ var re_btou = new RegExp([
+ '[\xC0-\xDF][\x80-\xBF]',
+ '[\xE0-\xEF][\x80-\xBF]{2}',
+ '[\xF0-\xF7][\x80-\xBF]{3}'
+ ].join('|'), 'g');
+ var cb_btou = function(cccc) {
+ switch(cccc.length) {
+ case 4:
+ var cp = ((0x07 & cccc.charCodeAt(0)) << 18)
+ | ((0x3f & cccc.charCodeAt(1)) << 12)
+ | ((0x3f & cccc.charCodeAt(2)) << 6)
+ | (0x3f & cccc.charCodeAt(3)),
+ offset = cp - 0x10000;
+ return (fromCharCode((offset >>> 10) + 0xD800)
+ + fromCharCode((offset & 0x3FF) + 0xDC00));
+ case 3:
+ return fromCharCode(
+ ((0x0f & cccc.charCodeAt(0)) << 12)
+ | ((0x3f & cccc.charCodeAt(1)) << 6)
+ | (0x3f & cccc.charCodeAt(2))
+ );
+ default:
+ return fromCharCode(
+ ((0x1f & cccc.charCodeAt(0)) << 6)
+ | (0x3f & cccc.charCodeAt(1))
+ );
}
- if (nextCharacter == 'A') return 0;
+ };
+ var btou = function(b) {
+ return b.replace(re_btou, cb_btou);
+ };
+ var cb_decode = function(cccc) {
+ var len = cccc.length,
+ padlen = len % 4,
+ n = (len > 0 ? b64tab[cccc.charAt(0)] << 18 : 0)
+ | (len > 1 ? b64tab[cccc.charAt(1)] << 12 : 0)
+ | (len > 2 ? b64tab[cccc.charAt(2)] << 6 : 0)
+ | (len > 3 ? b64tab[cccc.charAt(3)] : 0),
+ chars = [
+ fromCharCode( n >>> 16),
+ fromCharCode((n >>> 8) & 0xff),
+ fromCharCode( n & 0xff)
+ ];
+ chars.length -= [0, 0, 2, 1][padlen];
+ return chars.join('');
+ };
+ var atob = global.atob ? function(a) {
+ return global.atob(a);
+ } : function(a){
+ return a.replace(/[\s\S]{1,4}/g, cb_decode);
+ };
+ var _decode = buffer ? function(a) {
+ return (a.constructor === buffer.constructor
+ ? a : new buffer(a, 'base64')).toString();
}
- return END_OF_INPUT;
-}
-function ntos(n){
- n=n.toString(16);
- if (n.length == 1) n="0"+n;
- n="%"+n;
- return unescape(n);
-}
-
-function decodeBase64(str){
- setBase64Str(str);
- var result = "";
- var inBuffer = new Array(4);
- var done = false;
- while (!done && (inBuffer[0] = readReverseBase64()) != END_OF_INPUT
- && (inBuffer[1] = readReverseBase64()) != END_OF_INPUT){
- inBuffer[2] = readReverseBase64();
- inBuffer[3] = readReverseBase64();
- result += ntos((((inBuffer[0] << 2) & 0xff)| inBuffer[1] >> 4));
- if (inBuffer[2] != END_OF_INPUT){
- result += ntos((((inBuffer[1] << 4) & 0xff)| inBuffer[2] >> 2));
- if (inBuffer[3] != END_OF_INPUT){
- result += ntos((((inBuffer[2] << 6) & 0xff) | inBuffer[3]));
- } else {
- done = true;
- }
- } else {
- done = true;
- }
+ : function(a) { return btou(atob(a)) };
+ var decode = function(a){
+ return _decode(
+ String(a).replace(/[-_]/g, function(m0) { return m0 == '-' ? '+' : '/' })
+ .replace(/[^A-Za-z0-9\+\/]/g, '')
+ );
+ };
+ var noConflict = function() {
+ var Base64 = global.Base64;
+ global.Base64 = _Base64;
+ return Base64;
+ };
+ // export Base64
+ global.Base64 = {
+ VERSION: version,
+ atob: atob,
+ btoa: btoa,
+ fromBase64: decode,
+ toBase64: encode,
+ utob: utob,
+ encode: encode,
+ encodeURI: encodeURI,
+ btou: btou,
+ decode: decode,
+ noConflict: noConflict
+ };
+ // if ES5 is available, make Base64.extendString() available
+ if (typeof Object.defineProperty === 'function') {
+ var noEnum = function(v){
+ return {value:v,enumerable:false,writable:true,configurable:true};
+ };
+ global.Base64.extendString = function () {
+ Object.defineProperty(
+ String.prototype, 'fromBase64', noEnum(function () {
+ return decode(this)
+ }));
+ Object.defineProperty(
+ String.prototype, 'toBase64', noEnum(function (urisafe) {
+ return encode(this, urisafe)
+ }));
+ Object.defineProperty(
+ String.prototype, 'toBase64URI', noEnum(function () {
+ return encode(this, true)
+ }));
+ };
}
- return result;
+ // that's it!
+})(this);
+
+if (this['Meteor']) {
+ Base64 = global.Base64; // for normal export in Meteor.js
}
diff --git a/scripts/ems/web/bilingual-concordance.css b/scripts/ems/web/bilingual-concordance.css
index e232337d2..4648a21dd 100644
--- a/scripts/ems/web/bilingual-concordance.css
+++ b/scripts/ems/web/bilingual-concordance.css
@@ -93,5 +93,6 @@ span.mismatch_aligned {
td.pp_more {
font-size: 70%;
+ color: navy;
text-align: center;
}
diff --git a/scripts/ems/web/index.php b/scripts/ems/web/index.php
index 6b785cf3f..d216b114a 100644
--- a/scripts/ems/web/index.php
+++ b/scripts/ems/web/index.php
@@ -8,7 +8,7 @@ require("diff.php");
require("sgviz.php");
function head($title) {
- print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+ print '<!DOCTYPE html>
<html><head><title>'.$title.'</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script language="javascript" src="javascripts/prototype.js"></script>
diff --git a/scripts/ems/web/javascripts/scriptaculous-js-1.8.3/README.rdoc b/scripts/ems/web/javascripts/scriptaculous-js-1.8.3/README.rdoc
index 21f8c8cf6..57f78eb53 100644
--- a/scripts/ems/web/javascripts/scriptaculous-js-1.8.3/README.rdoc
+++ b/scripts/ems/web/javascripts/scriptaculous-js-1.8.3/README.rdoc
@@ -32,8 +32,8 @@ in a directory of your website, e.g. /javascripts.
Now, you can include the scripts by adding the following
tags to the HEAD section of your HTML pages:
- <script src="/javascripts/prototype.js" type="text/javascript"></script>
- <script src="/javascripts/scriptaculous.js" type="text/javascript"></script>
+ <script src="javascripts/prototype.js" type="text/javascript"></script>
+ <script src="javascripts/scriptaculous.js" type="text/javascript"></script>
scriptaculous.js will automatically load the other files of the
script.aculo.us distribution in, provided they are accessible
@@ -56,4 +56,4 @@ the sources of the examples provided.
== License
script.aculo.us is licensed under the terms of the MIT License,
-see the included MIT-LICENSE file. \ No newline at end of file
+see the included MIT-LICENSE file.
diff --git a/scripts/ems/web/overview.php b/scripts/ems/web/overview.php
index e56ed6f08..ce0434bb8 100644
--- a/scripts/ems/web/overview.php
+++ b/scripts/ems/web/overview.php
@@ -1,6 +1,5 @@
<?php
-date_default_timezone_set('Europe/London');
function setup() {
$setup = file("setup");
@@ -13,7 +12,7 @@ function setup() {
print "<TR><TD><A HREF=\"?setup=$dir[0]\">$dir[0]</A></TD><TD>$dir[1]</TD><TD>$dir[2]</TD><TD>$dir[3]</TD></TR>\n";
}
print "</TABLE>\n";
- print "<P>To add experiment, edit /fs/thor4/html/experiment/setup";
+ print "<p>To add experiment, edit the \"setup\" file.</p>";
}
function overview() {
@@ -26,7 +25,7 @@ function overview() {
head("Task: $task ($user)");
print "<a href=\"http://www.statmt.org/wiki/?n=Experiment.$setup\">Wiki Notes</a>";
- print " &nbsp; &nbsp; | &nbsp; &nbsp; <a href=\"/\">Overview of experiments</a> &nbsp; &nbsp; | &nbsp; &nbsp; <code>$dir</code><p>";
+ print " &nbsp; &nbsp; | &nbsp; &nbsp; <a href=\"?\">Overview of experiments</a> &nbsp; &nbsp; | &nbsp; &nbsp; <code>$dir</code><p>";
reset($experiment);
print "<form action=\"\" method=get>\n";