Assignment 3 Part 4 (submitted by Jun on Feb 10, 17:46)

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   Scott   Thanh   Varun

Download this file.

COMMENTS

Feb 16, 13:48 - Peter: Adding some explanatory comments would have made this a little more readable.

Feb 16, 13:54 - Peter: The module is good at being concise.

Feb 17, 12:44 - Ping: If you suggest adding comments, please try to be more specific about what you think needs explanation.

Feb 23, 16:19 - Ping (lines 12, 20): You don't need to declare these global because you're not reassigning them, you're just using them.

Feb 23, 16:20 - Ping (line 9): This function only adds data to myDocList, but the words never seem to get stored into myDict.

Please log in if you would like to add comments.

   

  1 myDocList = []
  2 myDict = {}
  3 
  4 def tokenizeDoc(myFile):
  5     global myDocList
  6     file = open(myFile)
  7 
  8     for line in file:
  9         myDocList.extend(line.split())
 10 
 11 def bestMatch(word):
 12     global myDict
 13     
 14     if myDict.get(word) == None:
 15         return []
 16     else:
 17         return myDict[word].split()
 18 
 19 def addWord(word):
 20     global myDict
 21 
 22     myDict[word] = word