Assignment 3 Part 1 (submitted by Adam on Feb 9, 22:40)

Beautiful Code
Ka-Ping Yee

AUTHORS:   Adam   Calvin   Chris   David   Derek   Hunter   Jacob   Jason   Jun   Karl   Kevin   Michael   Morgan   Nadia   Nerissa   Omair   Peter   Peterson   Ping   Richard   Rosie   Scott   Thanh   Varun

Download this file.

COMMENTS

Feb 15, 17:28 - David (line 17): this is a good way to count the occurences of each word.

Feb 15, 17:29 - David (line 16): split() only works on strings, but mispelled_words is supposed to be a list.

Feb 15, 18:32 - David (line 7): checkPassage is already defined in speling.

Please log in if you would like to add comments.

   

  1 #Welcome to Spell Check
  2 
  3 import speling
  4 file = open('input.txt')
  5 speling.checkPassage(file)
  6 
  7 #def checkPassage(passageStr)  
  8     #"""Checks to make sure all the words in the passage are  
  9      #spelled correctly.  
 10      #"""  
 11      #pass
 12 #count
 13 
 14 #assuming mispelled_words is a list returned from the checkPassage function.
 15     result={}
 16     mispelled_words = mispelled_words.split()
 17     for word in mispelled_words:
 18         if word in result:
 19             result[word] = result.get(word) + 1
 20         else:
 21             result[word] = 1
 22     return result