Skip to content

Commit

Permalink
#531 fixed bug: empty translation at the beginning of the most_accura…
Browse files Browse the repository at this point in the history
…te_approach
  • Loading branch information
nicolay-r committed Oct 22, 2023
1 parent b26c99f commit 012f6de
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions arekit/contrib/utils/pipelines/items/text/translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,14 @@ def __optionally_register(prts):
# Compose text parts.
translated_parts = self.__translate(content)

if len(translated_parts) == 0:
return None

# Take the original text.
text = translated_parts[0]
for entity_index in range(len(origin_entities)):
if entity_placeholder_template.format(entity_index) not in text:
return []
return None

# Enumerate entities.
from_ind = 0
Expand Down Expand Up @@ -129,4 +132,4 @@ def apply_core(self, input_data, pipeline_ctx):

fast_accurate = self.fast_most_accurate_approach(input_data)
return self.default_pre_part_splitting_approach(input_data) \
if len(fast_accurate) == 0 else fast_accurate
if fast_accurate is None else fast_accurate

0 comments on commit 012f6de

Please sign in to comment.