Replace word_count with maximum_length in if clause

This commit is contained in:
Leon Luithlen 2024-11-13 15:53:44 +01:00
parent 9b2fb09c59
commit 9ea2634480

View file

@ -15,7 +15,7 @@ def chunk_by_sentence(data: str, maximum_length: Optional[int] = None):
sentence += word
word_count += 1
if word_type == "paragraph_end" or word_type == "sentence_end" or ((word_count is not None) and (word_count == maximum_length)):
if word_type == "paragraph_end" or word_type == "sentence_end" or ((maximum_length is not None) and (word_count == maximum_length)):
yield (paragraph_id, chunk_index, sentence, word_count, word_type)
sentence = ""
word_count = 0