Skip to content

Commit

Permalink
Fix crash tokenizing with empty word_to_id (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
mgraczyk authored Oct 25, 2024
1 parent e06ecf4 commit f77e90d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion bm25s/tokenization.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ def streaming_tokenize(

if len(doc_ids) == 0 and allow_empty is True:
if update_vocab is True and "" not in self.word_to_id:
self.word_to_id[""] = max(self.word_to_id.values()) + 1
self.word_to_id[""] = max(self.word_to_id.values(), default=0) + 1

# get the ID for the empty string
if "" in self.word_to_id:
Expand Down

0 comments on commit f77e90d

Please sign in to comment.