Skip to content

Instantly share code, notes, and snippets.

Created June 24, 2015 03:24
Show Gist options
  • Save anonymous/7f3ab5183d519b0a8e80 to your computer and use it in GitHub Desktop.
Save anonymous/7f3ab5183d519b0a8e80 to your computer and use it in GitHub Desktop.
worddict = set()
with open ('words.txt') as fh:
lines = fh.readlines()
for element in lines:
words = element.rstrip()
worddict.add(words)
print '{0} words in spelling words'.format(len(worddict))
with open ('3-2_example.txt') as ex:
exlines = ex.read().split()
count = 0
for exelement in exlines:
count = count + 1
exwords = exelement.strip('.').strip(',').strip(';').strip(':').lower()
if exwords not in worddict:
print 'misspelled word on line {0}: {1}'.format(count, exwords)
@muxueqz
Copy link

muxueqz commented Jun 24, 2015

worddict = set()
with open ('words.txt') as fh:
    lines = fh.readlines()
    for element in lines:
        words = element.rstrip()
        worddict.add(words)
print '{0} words in spelling words'.format(len(worddict))


with open ('3-2_example.txt') as ex:
#    exlines = ex.read().split()
#    exlines = ex.read().split('\n')
    count = 0 
#    for exelement in exlines:
    for line in ex.readlines():
        count = count + 1
        for exelement in line.split():
            exwords = exelement.strip('.').strip(',').strip(';').strip(':').lower()
            if exwords not in worddict:
                print 'misspelled word on line {0}: {1}'.format(count, exwords)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment