Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions core/_4_2_translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,12 @@ def split_chunks_by_chars(chunk_size, max_i):
sentence_count = 0
for sentence in sentences:
if len(chunk) + len(sentence + '\n') > chunk_size or sentence_count == max_i:
chunks.append(chunk.strip())
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for the first time, enter this loop, chunk is '', so chunks will append a redundant empty str

chunk = sentence + '\n'
sentence_count = 1
else:
chunk += sentence + '\n'
sentence_count += 1
chunks.append(chunk.strip())
chunks.append(chunk.strip())
return chunks

# Get context from surrounding chunks
Expand Down Expand Up @@ -109,4 +108,4 @@ def translate_all():
console.print("[bold green]✅ Translation completed and results saved.[/bold green]")

if __name__ == '__main__':
translate_all()
translate_all()