Skip to content

Commit db552f9

Browse files
committed
Merge branch 'pr/5' into dev
2 parents f6854f3 + a8a7ab2 commit db552f9

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/semchunk/semchunk.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def merge_splits(splits: list[str], chunk_size: int, splitter: str, token_counte
7373

7474
tokens = token_counter(splitter.join(splits[:midpoint]))
7575

76-
average = cumulative_lengths[midpoint] / tokens if cumulative_lengths[midpoint] else average
76+
average = cumulative_lengths[midpoint] / tokens if cumulative_lengths[midpoint] and tokens > 0 else average
7777

7878
if tokens > chunk_size:
7979
high = midpoint
@@ -256,4 +256,4 @@ def chunker(text_or_texts: str | Sequence[str]) -> list[str] | list[list[str]]:
256256

257257
return [chunk(text, chunk_size, token_counter, memoize = False) for text in text_or_texts]
258258

259-
return chunker
259+
return chunker

0 commit comments

Comments
 (0)