Skip to content

Commit

Permalink
#416 fix
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolay-r committed Nov 25, 2022
1 parent 0b3e187 commit de81638
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions arekit/contrib/utils/pipelines/items/text/translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ def apply_core(self, input_data, pipeline_ctx):
assert(isinstance(pipeline_ctx, PipelineContext))
assert(isinstance(input_data, list))

def __optionally_register(prts_to_join):
if len(prts_to_join) > 0:
content.append(" ".join(prts_to_join))
parts_to_join.clear()

content = []
origin_entities = []
origin_entity_ind = []
Expand All @@ -35,15 +40,13 @@ def apply_core(self, input_data, pipeline_ctx):
parts_to_join.append(part)
elif isinstance(part, Entity):
# Register first the prior parts were merged.
content.append(" ".join(parts_to_join))
parts_to_join.clear()
__optionally_register(parts_to_join)
# Register entities information for further restoration.
origin_entity_ind.append(len(content))
origin_entities.append(part)
content.append(part.Value)

if len(parts_to_join) > 0:
content.append(" ".join(parts_to_join))
__optionally_register(parts_to_join)

# Compose text parts.
translated_parts = [part.text for part in
Expand Down

0 comments on commit de81638

Please sign in to comment.