Skip to content

Commit

Permalink
handle index out of range error
Browse files Browse the repository at this point in the history
  • Loading branch information
nandajavarma committed Aug 20, 2024
1 parent 9521929 commit f0ad13c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions app/readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ def read_vocab(vocab_file):
vocab = {}
reverse_vocab = {}
logprobs = []
with open(vocab_file) as f:
with open(vocab_file, encoding='utf-8') as f:
for l in f:
l = l.rstrip('\n')
vocab_list = l.split()
if len(vocab_list) <= 2:
l = l.rstrip('\n').strip() # Remove any trailing newline and extra spaces
vocab_list = l.rsplit(maxsplit=1)
if len(vocab_list) < 2:
print("Couldn't split the line:", l)
continue
wp = vocab_list[0]
Expand Down

0 comments on commit f0ad13c

Please sign in to comment.