# HW#3 Two Inaugural Speeches: Washington (1789) vs. Obama (2009) import textproc wfile = '1789-washington.txt' ofile = '2009-obama.txt' f = open(wfile) wtext = f.read() f.close() f = open(ofile) otext = f.read() f.close() # Open the output file for writing. fout = open('HW3.inaugural.OUT.txt', 'w') fout.write('Question 2: text length ----------------------------------------\n') # [Q2] Uncomment the 4 lines below: #wtoks = textproc.getToks(wtext) #otoks = textproc.getToks(otext) #fout.write('Washington speech has '+str(len(wtoks))+' tokens.\n') #fout.write('Obama speech has '+str(len(otoks))+' tokens.\n') fout.write('\nQuestion 3: vocabulary diversity -------------------------------\n') # [Q3] YOUR CODE BELOW: fout.write('\nQuestion 4: sentence length ------------------------------------\n') # [Q4] YOUR CODE BELOW: fout.write('\nQuestion 5: word length ----------------------------------------\n') # [Q5] YOUR CODE BELOW: fout.write('\nQuestion 6: top 20 Washington words ----------------------------\n') # [Q6] YOUR CODE BELOW: fout.write('\nQuestion 7: top 20 Obama words ---------------------------------\n') # [Q7] YOUR CODE BELOW: fout.write('\nQuestion 8: frequent words found in one speech only ------------\n') # [Q8] YOUR CODE BELOW: fout.write('\nQuestion 9: top 20 favored by Washington -----------------------\n') # [Q9] YOUR CODE BELOW: fout.write('\nQuestion 10: top 20 favored by Obama ---------------------------\n') # [Q10] YOUR CODE BELOW: fout.write('\nQuestion 11: your own question ---------------------------------\n') # [Q11] YOUR CODE BELOW: # Closing the output file. fout.close()