mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-21 02:39:31 -06:00
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
This commit is contained in:
@@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
<body class=hover>
|
<body class=hover>
|
||||||
<div class=pagehead>
|
<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>
|
<form name=options>
|
||||||
<table class=menubar>
|
<table class=menubar>
|
||||||
<tr><td><span onclick="">File</span>
|
<tr><td><span onclick="">File</span>
|
||||||
@@ -78,7 +78,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<hr>
|
<hr>
|
||||||
<div class=modtime><small>HMTL
|
<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>
|
</small></div>
|
||||||
<a href="about.html">About</a>
|
<a href="about.html">About</a>
|
||||||
|
|
||||||
|
|||||||
@@ -212,10 +212,12 @@ Translator.prototype.update_translation=function(i) {
|
|||||||
else {
|
else {
|
||||||
var ts=[]
|
var ts=[]
|
||||||
for(var i=0;i<trans.length;i++) {
|
for(var i=0;i<trans.length;i++) {
|
||||||
ts[i]=trans[i].linearizations[0].text
|
var t=trans[i].linearizations[0].text
|
||||||
if(punct) ts[i]=ts[i]+" "+punct
|
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) {
|
function upd0(source,punct) {
|
||||||
@@ -223,7 +225,7 @@ Translator.prototype.update_translation=function(i) {
|
|||||||
//console.log(translate_output)
|
//console.log(translate_output)
|
||||||
upd2(translate_output,punct)
|
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)
|
if(!window.gftranslate)
|
||||||
upd3s("[GF robust parser is not available]")
|
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"}
|
var want={from:o.from, to:o.to, method:"GFRobust"}
|
||||||
if(!eq_options(segment.options,want)) {
|
if(!eq_options(segment.options,want)) {
|
||||||
//console.log("Updating "+i)
|
//console.log("Updating "+i)
|
||||||
lexgfrobust(segment.source,upd0)
|
//lexgfrobust(segment.source,upd0)
|
||||||
//upd0(segment.source)
|
upd0(segment.source,"")
|
||||||
}
|
}
|
||||||
//else console.log("No update ",want,segment.options)
|
//else console.log("No update ",want,segment.options)
|
||||||
}
|
}
|
||||||
@@ -259,7 +261,10 @@ Translator.prototype.update_translation=function(i) {
|
|||||||
function upd2(ts) {
|
function upd2(ts) {
|
||||||
switch(ts.length) {
|
switch(ts.length) {
|
||||||
case 0: upd3(["[no translation]"]);break;
|
case 0: upd3(["[no translation]"]);break;
|
||||||
default: mapc(unlextext,ts,upd3); break;
|
default:
|
||||||
|
//mapc(unlextext,ts,upd3);
|
||||||
|
upd3(ts)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function upd1(translate_output) {
|
function upd1(translate_output) {
|
||||||
@@ -267,7 +272,8 @@ Translator.prototype.update_translation=function(i) {
|
|||||||
upd2(collect_texts(translate_output[0].translations))
|
upd2(collect_texts(translate_output[0].translations))
|
||||||
}
|
}
|
||||||
function upd0(source) {
|
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 fls=t.gf_supported(grammar,o.from)
|
||||||
var tls=t.gf_supported(grammar,o.to)
|
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}
|
var want={from:o.from, to:o.to, method:grammar}
|
||||||
if(!eq_options(segment.options,want)) {
|
if(!eq_options(segment.options,want)) {
|
||||||
//console.log("Updating "+i)
|
//console.log("Updating "+i)
|
||||||
lextext(segment.source,upd0)
|
//lextext(segment.source,upd0)
|
||||||
|
upd0(segment.source)
|
||||||
}
|
}
|
||||||
//else console.log("No update ",want,segment.options)
|
//else console.log("No update ",want,segment.options)
|
||||||
}
|
}
|
||||||
@@ -1173,6 +1180,7 @@ function save_in_cloud(filename,document,cont) {
|
|||||||
with_dir(save)
|
with_dir(save)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
// Like lextext, but separate punctuation from the end
|
// Like lextext, but separate punctuation from the end
|
||||||
function lexgfrobust(txt,cont) {
|
function lexgfrobust(txt,cont) {
|
||||||
function rmpunct(txt) {
|
function rmpunct(txt) {
|
||||||
@@ -1184,7 +1192,7 @@ function lexgfrobust(txt,cont) {
|
|||||||
}
|
}
|
||||||
lextext(txt,rmpunct)
|
lextext(txt,rmpunct)
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
/* --- DOM Support ---------------------------------------------------------- */
|
/* --- DOM Support ---------------------------------------------------------- */
|
||||||
|
|
||||||
function a(url,linked) { return node("a",{href:url},linked); }
|
function a(url,linked) { return node("a",{href:url},linked); }
|
||||||
|
|||||||
Reference in New Issue
Block a user