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")
|
@hook.command("spellcheck")
|
||||||
def spell(inp):
|
def spell(inp):
|
||||||
"spell <word> -- Check spelling of <word>."
|
"spell <word> -- Check spelling of <word>."
|
||||||
word = inp
|
|
||||||
|
if ' ' in inp:
|
||||||
if ' ' in word:
|
|
||||||
return "This command only supports one word at a time."
|
return "This command only supports one word at a time."
|
||||||
|
|
||||||
if not enchant.dict_exists(locale):
|
if not enchant.dict_exists(locale):
|
||||||
return "Could not find dictionary: %s" % locale
|
return "Could not find dictionary: %s" % locale
|
||||||
|
|
||||||
dict = enchant.Dict(locale)
|
dict = enchant.Dict(locale)
|
||||||
|
is_correct = dict.check(inp)
|
||||||
is_correct = dict.check(word)
|
suggestions = dict.suggest(inp)
|
||||||
suggestions = dict.suggest(word)
|
|
||||||
s_string = ', '.join(suggestions[:10])
|
s_string = ', '.join(suggestions[:10])
|
||||||
|
|
||||||
if is_correct:
|
if is_correct:
|
||||||
return '"%s" appears to be \x02valid\x02! ' \
|
return '"%s" appears to be \x02valid\x02! ' \
|
||||||
'(suggestions: %s)' % (word, s_string)
|
'(suggestions: %s)' % (inp, s_string)
|
||||||
else:
|
else:
|
||||||
return '"%s" appears to be \x02invalid\x02! ' \
|
return '"%s" appears to be \x02invalid\x02! ' \
|
||||||
'(suggestions: %s)' % (word, s_string)
|
'(suggestions: %s)' % (inp, s_string)
|
||||||
|
|
Reference in a new issue