Assignment 3 Part 1 (submitted by Calvin on Feb 8, 22:05)

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, 20:13 - Varun: Very nice code, short and makes good use of the python api

Feb 15, 20:14 - Varun (line 11): Could really use comments at various places to explain what program is doing at various parts.

Feb 17, 12:43 - Ping: Can you be more specific with your last suggestion?

Please log in if you would like to add comments.

   

  1 # Calvin Smith
  2 # Craft 3, part uno
  3 
  4 import speling
  5 
  6 speling.LoadDic('dict.txt')
  7 
  8 # speling.SpellCheck('input.txt')
  9 # too easy to use this, so don't use this function
 10 
 11 text = open('input.txt', 'r').read()
 12 sents = []
 13 for symbol in '\n(),-?\"\&$#@!%^*_=+/\\;:'0123456789:
 14     text = text.replace(symbol, ' ')
 15     sents = text.split('.')
 16     
 17 mispeledwords = {}
 18 for sent in sents:
 19     mispeled = CheckSent(sent)
 20     for word in mispeled:
 21         if mispeledwords.get('word', None):
 22             mispeledwords['word'] = mispeledwords['word'] + 1
 23         else:
 24             mispeledwords['word'] = 1
 25 keys = mispeledwords.keys()
 26 keys.sort()
 27 for key in keys:
 28     print key, '(' + str(mispeledwords[key]) + ')'