forked from GitHub/gf-core
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user