imjunaidafzal commited on
Commit
f41473e
1 Parent(s): f95ea9d

handle UnboundLocalError in ar_spelling_checker

Browse files

You forgot to initialize tmp_corrections, when` if not word in vocab:` becomes `false`, exception occur at line 127:
`UnboundLocalError: local variable 'tmp_corrections' referenced before assignment`

Files changed (1) hide show
  1. app.py +1 -0
app.py CHANGED
@@ -123,6 +123,7 @@ def ar_spelling_checker(text):
123
  result = {}
124
 
125
  for word in word_l:
 
126
  if not word in vocab:
127
  tmp_corrections = get_corrections(word, vocab)
128
  if len(tmp_corrections) == 0:
 
123
  result = {}
124
 
125
  for word in word_l:
126
+ tmp_corrections = []
127
  if not word in vocab:
128
  tmp_corrections = get_corrections(word, vocab)
129
  if len(tmp_corrections) == 0: