Merge pull request #146 from hunkim/patch-1

Add handling for last chunk in split_into_sentences function
pull/1077/head
Ted Sanders 2 years ago committed by GitHub
commit dfc4374fae

@ -248,6 +248,10 @@ def split_into_many(text, max_tokens = max_tokens):
# Otherwise, add the sentence to the chunk and add the number of tokens to the total
chunk.append(sentence)
tokens_so_far += token + 1
# Add the last chunk to the list of chunks
if chunk:
chunks.append(". ".join(chunk) + ".")
return chunks

Loading…
Cancel
Save