1
0
forked from GitHub/gf-core

Wide Coverage Demo App (gftranslate.js): use a special lexer for Chinese.

This commit is contained in:
hallgren
2014-04-11 18:39:12 +00:00
parent 6601a3972e
commit ba825ae81a

View File

@@ -15,12 +15,14 @@ gftranslate.call=function(querystring,cont) {
// Translate a sentence
gftranslate.translate=function(source,from,to,start,limit,cont) {
var encsrc=encodeURIComponent(source)
var g=gftranslate.grammar
var lexer="&lexer=text"
if(from=="Chi") lexer="",source=source.split("").join(" ")
var encsrc=encodeURIComponent(source)
function extract(result) { cont(result[0].translations) }
if(encsrc.length<500)
gftranslate.call("?command=c-translate&input="+encsrc
+"&lexer=text&unlexer=text&from="+g+from+"&to="+g+to
+lexer+"&unlexer=text&from="+g+from+"&to="+g+to
+"&start="+start+"&limit="+limit,extract)
else cont([{error:"sentence too long"}])
}