js/gfrobust.js: don't try to translate sentenses that are too long

The C run-time responds badly to input that is too long, so we return an
error message here instead.
The limit is 200 URL-encoded characters.
This commit is contained in:
hallgren
2013-04-23 13:40:38 +00:00
parent d6c01c5414
commit dade5c1194

View File

@@ -14,8 +14,10 @@ gfrobust.call=function(querystring,cont) {
// Translate a sentence to the given target language
gfrobust.translate=function(source,to,cont) {
var enc=encodeURIComponent
gfrobust.call("?sentence="+enc(source)+"&to="+gfrobust.grammar+to,cont)
var encsrc=encodeURIComponent(source)
if(encsrc.length<200) // match limit in runtime/c/utils/pgf-server.c
gfrobust.call("?sentence="+encsrc+"&to="+gfrobust.grammar+to,cont)
else cont("[GF robust parser: sentence too long]")
}
// Get the url of a parse tree image (SVG)