Created
March 10, 2016 20:01
-
-
Save omz/e141f676504b743dbaa8 to your computer and use it in GitHub Desktop.
Spellcheck word.py
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
# coding: utf-8 | |
from objc_util import ObjCClass | |
UITextChecker = ObjCClass('UITextChecker') | |
def check_word(word, lang='en_US'): | |
c = UITextChecker.new().autorelease() | |
check = c.rangeOfMisspelledWordInString_range_startingAt_wrap_language_ | |
misspelled_range = check(word, (0, len(word)), 0, False, lang) | |
return (misspelled_range.location != 0) | |
test_words = ['foo', 'bar', 'baz', 'quuz', 'cat', 'dog'] | |
for word in test_words: | |
print '%s: %s' % (word, check_word(word)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment