forked from GitHub/gf-core
Wide Coverage Demo App (gftranslate.js): use a special lexer for Chinese.
This commit is contained in:
@@ -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"}])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user