Skip to content

Commit

Permalink
Add an error check in WordsDictionary.Parse.
Browse files Browse the repository at this point in the history
#codehealth

PiperOrigin-RevId: 670111949
  • Loading branch information
hiroyuki-komatsu committed Sep 2, 2024
1 parent 9c53503 commit 19f2e31
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/dictionary/gen_aux_dictionary.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,11 @@ def Parse(self, words_tsv, id_def, ratio=0.5):
if line.startswith('#') or not line.rstrip():
continue

key, value, pos = line.rstrip().split('\t')
items = line.rstrip().split('\t')
if len(items) != 3:
print(f'Error: invalid format: "{line}"', file=sys.stderr)
sys.exit(1)
key, value, pos = items
pos_id = pos_ids.GetId(pos)
if not pos_id:
print('Error: ' + pos + ' is an invalid pos', file=sys.stderr)
Expand Down

0 comments on commit 19f2e31

Please sign in to comment.