bwignall/typochecker

KeyError by ignoring a typo with multiple cases

Opened this issue · 0 comments

Steps to reproduce:

$ cat << EOF > typo.txt
Typo: Abilty (title)
Typo: abilty (lower)
EOF
$ python3 -m typochecker.corrector -d .
Getting list of typos
Information from https://en.wikipedia.org/wiki/Wikipedia:Lists_of_common_misspellings/For_machines
opening /tmp/typochecker/typochecker/../data/wikipedia_common_misspellings.txt
opening /tmp/typochecker/typochecker/../data/extra_endings.txt
Will search through 1 files
Suggestions follow for file ./typo.txt
file_typos: ['Abilty', 'abilty']
Typo: Abilty (title)

     ^^^^^^^^^
Suggestion: Ability
Correction ("!h" for help), default to Ability: !i
Traceback (most recent call last):
  File "/tmp/typochecker/typochecker/corrector.py", line 237, in <module>
    res = iterate_over_file(search_file, typos, file_typos)
  File "/tmp/typochecker/typochecker/corrector.py", line 127, in iterate_over_file
    all_typos.get(matched_typo, None) or all_typos[matched_typo.lower()], matched_typo)
KeyError: 'abilty'

I took a glance but cannot find the cause.