From 2b182c4e634b5270b929ef3968725eb9489f8fdc Mon Sep 17 00:00:00 2001 From: hallgren Date: Thu, 12 May 2016 17:53:56 +0000 Subject: Wide Coverage Translation Demo: select application grammars to use from a list There is now a new button "Grammars..." which show a list where users can select which application grammars to use for translation, in addition to the wide coverage grammar. Application grammars can give higher quality translations in the domain they cover. TODO: make it possible control the order of the selected application grammars. --- src/www/js/wc.js | 100 +++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 86 insertions(+), 14 deletions(-) (limited to 'src/www/js') diff --git a/src/www/js/wc.js b/src/www/js/wc.js index c32d0f2e8..99fcf2edb 100644 --- a/src/www/js/wc.js +++ b/src/www/js/wc.js @@ -2,12 +2,14 @@ /* --- Wide Coverage Translation Demo web app ------------------------------- */ var wc={} -//wc.cnl="Phrasebook" // try this controlled natural language first +wc.selected_cnls=[] // list of grammar names +wc.cnls={} // maps grammars names to {pgf_online:...,grammar_info:{...}} wc.f=document.forms[0] wc.o=element("output") wc.e=element("extra") wc.i=element("grammarinfo") wc.p=element("pick") +wc.grammarbox=element("grammarbox") wc.os=[] /* output segment list [{input,text:String; from,to::Lang; target:Node; @@ -42,6 +44,7 @@ wc.save=function() { wc.local.put("to",f.to.value) wc.local.put("input",f.input.value) wc.local.put("colors",f.colors.checked) + wc.local.put("cnls",wc.selected_cnls) } } @@ -52,6 +55,7 @@ wc.load=function() { f.from.value=wc.local.get("from",f.from.value) f.to.value=wc.local.get("to",f.to.value) f.colors.checked=wc.local.get("colors",f.colors.checked) + wc.selected_cnls=wc.local.get("cnls",wc.selected_cnls) wc.colors() wc.delayed_translate() } @@ -249,25 +253,31 @@ wc.translate=function() { gftranslate.translate(text,f.from.value,wc.languages || f.to.value,i,count,step3) } function step2(text) { trans(text,0,10) } - function step2cnl(text) { + function step2cnl(text,ix) { function step3cnl(results) { var trans=results[0].translations if(trans && trans.length>=1) { for(var i=0;i