filyp / autocorrect

Spelling corrector in python
GNU Lesser General Public License v3.0
448 stars 79 forks source link

Uncaught Exception for Empty String #6

Closed JimmyCarlos closed 4 years ago

JimmyCarlos commented 4 years ago

Hiya,

First of all, big thanks for all the work on this project, it's awesome and super-lightweight, making it perfect for my project, which is going to be used to support hundreds of children with their education.

My project crashed today though, and in debugging I found it was because of autocorrect. Here's a minimally reproducible example of the error:

from autocorrect import Speller
autocorrector = Speller()
part_given = ""
part_given = autocorrector.autocorrect_word(part_given)

I was expecting this to keep part_given as "", but instead it throws up an IndexError.

With best wishes, JimmyCarlos.

filyp commented 4 years ago

Ah, I'm glad it's useful to you ^^ Thanks for finding this bug, I should fix this in a couple of days. For now you can just call:

part_given = autocorrector(part_given)

Which works fine.

filyp commented 4 years ago

Fixed in https://github.com/fsondej/autocorrect/commit/c41708a186994cc52c45e9447aee3082bcd33915