diff options
| author | hallgren <hallgren@chalmers.se> | 2014-04-11 12:10:05 +0000 |
|---|---|---|
| committer | hallgren <hallgren@chalmers.se> | 2014-04-11 12:10:05 +0000 |
| commit | ea389df58e52df93a22da4ef6d74a589ce1ee1f8 (patch) | |
| tree | 503b8c62e8dc6af6aab435721a107def18b9ac83 | |
| parent | f72fe45c32deccacb81de613ff9e7272b2500fa5 (diff) | |
Simple Translator: Use PGF API for (un)lexing instead of separate server calls
Also,
+ Get up to 10 (instead of 5) alternative robust translations.
+ Remove duplicates from list of alternative robust translations
+ Add GF Cloud logo to the simple translator page
| -rw-r--r-- | src/www/translator/index.html | 4 | ||||
| -rw-r--r-- | src/www/translator/translator.js | 28 |
2 files changed, 20 insertions, 12 deletions
diff --git a/src/www/translator/index.html b/src/www/translator/index.html index 394299eb4..f89350706 100644 --- a/src/www/translator/index.html +++ b/src/www/translator/index.html @@ -11,7 +11,7 @@ <body class=hover> <div class=pagehead> -<h1>Simple Translation Tool</h1> + <h1><img src="../P/gf-cloud.png" alt="" title="GF Cloud Service">Simple Translation Tool</h1> <form name=options> <table class=menubar> <tr><td><span onclick="">File</span> @@ -78,7 +78,7 @@ </div> <hr> <div class=modtime><small>HMTL -<!-- hhmts start -->Last modified: Wed Feb 19 15:07:10 CET 2014 <!-- hhmts end --> +<!-- hhmts start -->Last modified: Fri Apr 11 14:10:02 CEST 2014 <!-- hhmts end --> </small></div> <a href="about.html">About</a> diff --git a/src/www/translator/translator.js b/src/www/translator/translator.js index 63e86c01e..a89fd24e8 100644 --- a/src/www/translator/translator.js +++ b/src/www/translator/translator.js @@ -212,10 +212,12 @@ Translator.prototype.update_translation=function(i) { else { var ts=[] for(var i=0;i<trans.length;i++) { - ts[i]=trans[i].linearizations[0].text - if(punct) ts[i]=ts[i]+" "+punct + var t=trans[i].linearizations[0].text + if(punct) t=t+" "+punct + if(!elem(t,ts)) ts.push(t) } - mapc(unlextext,ts,upd3) + //mapc(unlextext,ts,upd3) + upd3(ts) } } function upd0(source,punct) { @@ -223,7 +225,7 @@ Translator.prototype.update_translation=function(i) { //console.log(translate_output) upd2(translate_output,punct) } - gftranslate.translate(source,o.from,o.to,0,5,upd1) + gftranslate.translate(source,o.from,o.to,0,10,upd1) } if(!window.gftranslate) upd3s("[GF robust parser is not available]") @@ -235,8 +237,8 @@ Translator.prototype.update_translation=function(i) { var want={from:o.from, to:o.to, method:"GFRobust"} if(!eq_options(segment.options,want)) { //console.log("Updating "+i) - lexgfrobust(segment.source,upd0) - //upd0(segment.source) + //lexgfrobust(segment.source,upd0) + upd0(segment.source,"") } //else console.log("No update ",want,segment.options) } @@ -259,7 +261,10 @@ Translator.prototype.update_translation=function(i) { function upd2(ts) { switch(ts.length) { case 0: upd3(["[no translation]"]);break; - default: mapc(unlextext,ts,upd3); break; + default: + //mapc(unlextext,ts,upd3); + upd3(ts) + break; } } function upd1(translate_output) { @@ -267,7 +272,8 @@ Translator.prototype.update_translation=function(i) { upd2(collect_texts(translate_output[0].translations)) } function upd0(source) { - server.translate({from:gfrom,to:gto,input:source},upd1) + server.translate({from:gfrom,to:gto,lexer:"text",unlexer:"text", + input:source},upd1) } var fls=t.gf_supported(grammar,o.from) var tls=t.gf_supported(grammar,o.to) @@ -275,7 +281,8 @@ Translator.prototype.update_translation=function(i) { var want={from:o.from, to:o.to, method:grammar} if(!eq_options(segment.options,want)) { //console.log("Updating "+i) - lextext(segment.source,upd0) + //lextext(segment.source,upd0) + upd0(segment.source) } //else console.log("No update ",want,segment.options) } @@ -1173,6 +1180,7 @@ function save_in_cloud(filename,document,cont) { with_dir(save) } +/* // Like lextext, but separate punctuation from the end function lexgfrobust(txt,cont) { function rmpunct(txt) { @@ -1184,7 +1192,7 @@ function lexgfrobust(txt,cont) { } lextext(txt,rmpunct) } - +*/ /* --- DOM Support ---------------------------------------------------------- */ function a(url,linked) { return node("a",{href:url},linked); } |
