a bunch of things

This commit is contained in:
Luke Rogers 2013-12-01 20:44:04 +13:00
parent 8317ba0920
commit 3e073c8278
2 changed files with 9 additions and 12 deletions

View file

@ -14,11 +14,11 @@ def spell(inp):
return "Could not find dictionary: {}".format(locale)
if len(inp.split(" ")) > 1:
# input is a sentence
chkr = SpellChecker(locale)
chkr.set_text(inp)
offset = 0
for err in chkr:
# find the location of the incorrect word
start = err.wordpos + offset
@ -31,9 +31,9 @@ def spell(inp):
offset = (offset + len(s_string)) - len(err.word)
# replace the word with the suggestions
inp = inp[:start] + s_string + inp[finish:]
return inp
else:
# input is a word
dictionary = enchant.Dict(locale)
is_correct = dictionary.check(inp)
suggestions = dictionary.suggest(inp)