User:Shardulc

From Apertium
Revision as of 18:24, 28 December 2016 by Shardulc (talk | contribs) (Copy to http://wiki.apertium.org/wiki/Apertium-apy#Usage, leave a backup)
Jump to navigation Jump to search

/translate Translate text

  • langpair: language pair to use for translation
  • q: text to translate
  • markUnknown=no (optional): include this to remove "*" in front of unknown words
  • deformat: deformatter to be used: one of html (default), txt, rtf
  • reformat: deformatter to be used: one of html, html-noent (default), txt, rtf
  • format: if deformatter and reformatter are the same, they can be specified here

For more about formatting, please see Format Handling. | To be consistent with ScaleMT, the returned JS Object contains a responseData key with an JS Object that has key translatedText that contains the translated text.

$ curl 'http://localhost:2737/translate?langpair=kaz|tat&q=Сен+бардың+ба?'
{"responseStatus": 200, "responseData": {"translatedText": "Син барныңмы?"}, "responseDetails": null}
$ echo Сен бардың ба? > myfile
$ curl --data-urlencode 'q@myfile' 'http://localhost:2737/translate?langpair=kaz|tat'
{"responseStatus": 200, "responseData": {"translatedText": "Син барныңмы?"}, "responseDetails": null}

The following two queries contain nonstandard whitespace characters and are equivalent:

$ curl 'http://localhost:2737/translate?langpair=eng|spa&q=This    works well&deformat=txt&reformat=txt'
{"responseStatus": 200, "responseData": {"translatedText": "Esto    trabaja\u2001bien"}, "responseDetails": null}
$ curl 'http://localhost:2737/translate?langpair=eng|spa&q=This    works well&format=txt'
{"responseStatus": 200, "responseData": {"translatedText": "Esto    trabaja\u2001bien"}, "responseDetails": null}

The following two queries illustrate the difference between the html and html-noent reformatter:

$ curl 'http://localhost:2737/translate?langpair=eng|spa&q=How does this work?&reformat=html'
{"responseData": {"translatedText": "Qué hace este trabajo?"}, "responseDetails": null, "responseStatus": 200}
$ curl 'http://localhost:2737/translate?langpair=eng|spa&q=How does this work?&reformat=html-noent'
{"responseData": {"translatedText": "Qu\u00e9 hace este trabajo?"}, "responseDetails": null, "responseStatus": 200}