Created
June 9, 2014 16:39
-
-
Save neanias/7f8691ef52ba561d0888 to your computer and use it in GitHub Desktop.
A small script to test autocorrect using the PyEnchant library
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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