mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-23 19:42:50 -06:00
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
|
// Translate a sentence to the given target language
|
||||||
gfrobust.translate=function(source,to,cont) {
|
gfrobust.translate=function(source,to,cont) {
|
||||||
var enc=encodeURIComponent
|
var encsrc=encodeURIComponent(source)
|
||||||
gfrobust.call("?sentence="+enc(source)+"&to="+gfrobust.grammar+to,cont)
|
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)
|
// Get the url of a parse tree image (SVG)
|
||||||
|
|||||||
Reference in New Issue
Block a user