Api

There's a very simple API available. You need to know only how to discover the available models and that you POST input_text to those models.

Start exploring the api by requesting application/json from /services/transformer/. You can then follow the links in the _links dictionary and navigate the api.

For convenience the models available in the latest api version are embedded (in the _embedded field of the response).

Errors are reported solely as the HTTP return status.

Examples

Enter the api
curl -H'Accept: application/json' "https://lindat.mff.cuni.cz:443/services/transformer/"
Get models titles:urls from the _embedded field
curl -s -H'Accept: application/json' "https://lindat.mff.cuni.cz:443/services/transformer/" | PYTHONIOENCODING=utf-8 python -c "import sys,json; sys.stdout.write('\n'.join ([model['title'] + ':' + model['href'] for model in json.load(sys.stdin) ['_embedded']['latest']['_embedded']['models']['_links']['models']]))"
Translate (when you've found the right model)
curl -d 'input_text=This is a test' https://lindat.mff.cuni.cz:443$(curl -s -H'Accept: application/json' https://lindat.mff.cuni.cz:443/services/transformer/ | PYTHONIOENCODING=utf-8 python -c "import sys,json; sys.stdout.write(json.load(sys.stdin)['_embedded']['latest']['_embedded']['models']['_links']['models'][0]['href'])")
Upload a file
curl -F input_text=@/tmp/test.txt https://lindat.mff.cuni.cz:443$(curl -s -H'Accept: application/json' https://lindat.mff.cuni.cz:443/services/transformer/ | PYTHONIOENCODING=utf-8 python -c "import sys,json; sys.stdout.write(json.load(sys.stdin)['_embedded']['latest']['_embedded']['models']['_links']['models'][0]['href'])")

For one off scripts you can also use the model endpoint and/or the urls of models provided by that endpoint, provided you don't mind updating them by hand from time to time.

With hardcoded en-cs model
curl -d 'input_text=This is a simple test.' https://lindat.mff.cuni.cz:443/services/transformer/api/v1/models/en-cs

Response

The response is a json array where each element is a translated sentence.

Limitations

See the terms of use for general limitations on lindat services.

There is a limitation on the size of the payload (file/request); this is currently 102400B

Credits: The service runs systems trained by Martin Popel as presented in en-cs; cs-en