Skip to content

Instantly share code, notes, and snippets.

@neanias
Created June 9, 2014 16:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neanias/7f8691ef52ba561d0888 to your computer and use it in GitHub Desktop.
Save neanias/7f8691ef52ba561d0888 to your computer and use it in GitHub Desktop.
A small script to test autocorrect using the PyEnchant library
# -*- encoding: utf-8 -*-
from sys import argv
from enchant import request_dict
if len(argv) <= 1:
print "USAGE: python basic_testing.py <sentence>"
exit()
else:
sentence = argv[1:]
gb_dict = request_dict('en_gb')
us_dict = request_dict('en_us')
for word in sentence:
if gb_dict.check(word) or us_dict.check(word):
print word, "| No correction needed (in either US or GB dict)"
else:
print word, "| %s first GB suggestion | %s first US suggestion" % \
(gb_dict.suggest(word)[0], us_dict.suggest(word)[0])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment