-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
I'm trying to pretranslate a list of raw strings. The easiest way to do this using the API seems to be uploading a document with pretranslation options enabled. Unfortunately it seems like submitting .txt files causes issues from the Python client.
My code below:
configuration = lilt.Configuration(
host = host,
api_key = {
'key': api_key
},
)
with lilt.ApiClient(configuration) as api_client:
api_instance = lilt.DocumentsApi(api_client)
name = 'dummy.txt'
project_id = 4
s = BytesIO("Hello, world!".encode())
body = s.read() .
pretranslate = 'tm+mt'
try:
api_response = api_instance.upload_document(name, project_id, body, pretranslate=pretranslate)
pprint(api_response)
except ApiException as e:
print("Exception when calling TranslateApi->translate_segment: %s\n" % e)The corresponding uploaded document in UI:
Perhaps I'm misunderstanding the API as I see the same behavior with cURL:
curl -k -X POST "$host/documents/files?key=$key" \
--header "LILT-API: {\"name\": \"test2.txt\",\"pretranslate\": \"tm+mt\",\"project_id\": 4}" \
--header "Content-Type: application/octet-stream" \
--data-binary @test.txtMetadata
Metadata
Assignees
Labels
No labels
