Pepping
This commit is contained in:
parent
2b4e5b3a98
commit
7bdbb376b8
1 changed files with 6 additions and 8 deletions
|
@ -8,23 +8,21 @@ locale = "en_US"
|
|||
@hook.command("spellcheck")
|
||||
def spell(inp):
|
||||
"spell <word> -- Check spelling of <word>."
|
||||
word = inp
|
||||
|
||||
if ' ' in word:
|
||||
|
||||
if ' ' in inp:
|
||||
return "This command only supports one word at a time."
|
||||
|
||||
if not enchant.dict_exists(locale):
|
||||
return "Could not find dictionary: %s" % locale
|
||||
|
||||
dict = enchant.Dict(locale)
|
||||
|
||||
is_correct = dict.check(word)
|
||||
suggestions = dict.suggest(word)
|
||||
is_correct = dict.check(inp)
|
||||
suggestions = dict.suggest(inp)
|
||||
s_string = ', '.join(suggestions[:10])
|
||||
|
||||
if is_correct:
|
||||
return '"%s" appears to be \x02valid\x02! ' \
|
||||
'(suggestions: %s)' % (word, s_string)
|
||||
'(suggestions: %s)' % (inp, s_string)
|
||||
else:
|
||||
return '"%s" appears to be \x02invalid\x02! ' \
|
||||
'(suggestions: %s)' % (word, s_string)
|
||||
'(suggestions: %s)' % (inp, s_string)
|
||||
|
|
Reference in a new issue