Merge pull request #146 from hunkim/patch-1
Add handling for last chunk in split_into_sentences function
This commit is contained in:
commit
8f06acdd82
1 changed files with 4 additions and 0 deletions
|
|
@ -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
|
# Otherwise, add the sentence to the chunk and add the number of tokens to the total
|
||||||
chunk.append(sentence)
|
chunk.append(sentence)
|
||||||
tokens_so_far += token + 1
|
tokens_so_far += token + 1
|
||||||
|
|
||||||
|
# Add the last chunk to the list of chunks
|
||||||
|
if chunk:
|
||||||
|
chunks.append(". ".join(chunk) + ".")
|
||||||
|
|
||||||
return chunks
|
return chunks
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue