generated from amazon-archives/__template_MIT-0
-
Notifications
You must be signed in to change notification settings - Fork 17
Open
Description
This would translate run by run (sometimes a run is a word), not sentence by sentence. I concatenated all the runs in a paragraph to make it translate better and faster. The drawback of my approach is that the format won't be preserved as well.
The below code starts from line 115.
for index, paragraph_run in enumerate(paragraph.runs): # concatenate all the runs
paraText += paragraph_run.text
if len(paraText) > 0:
try:
response = translate.translate_text(
Text=paraText,
SourceLanguageCode=source_language_code,
TargetLanguageCode=target_language_code,
TerminologyNames=terminology_names)
paragraph.clear()
run = paragraph.add_run()
run.text = response.get('TranslatedText')`
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels