This project will be due by 5 pm, Friday, September 12. To submit your
project, save it in the pp1
directory located in your directory under
/home/libs/dataStr/students/
on one of the department's Linux
machines (this is a shared directory, so you should be able to reach it
from any of the machines, including Jupiter).
You may work on this project by yourself or in a group of two or three. If you work in a group, be sure to include everyone's name in the comments at the top of each file. Also, be sure you understand the guidelines for group work listed in the syllabus--the fundamental idea is that everyone in the group should understand what everyone else has done, and be able to recreate it on their own.
The project is based on Programming Exercise 3-45 in the text (p. 180). However, instead of looking for a fixed list of keywords in the input, your program should first read a file containing the list of keywords. This file will not be in alphabetical order, so the next step will be to sort the keywords (just use the default ordering on strings--do not worry about upper- vs. lower-case issues). Now continue as described in the exercise: prompt the user for a file name, read the words in that file, and count the number of occurences of each keyword. After reading the entire file, your program should display a table giving the number of times each keyword occurred in the file, then quit.
For example, if the keyword file contains
that is not itand the second file contains
To be or not to be that is the question That that is is that that is not is not is that it it isthen the output should look something like
is 7 it 2 not 3 that 5(Note that the word ``That'' at the beginning of the second line is not counted, since it is not the same word as ``that''.)
For extra credit, sort the output by the frequency of the keywords, so
that the most common words come first. In the example above, this would
swap the lines for ``it'' and ``that''. Ideally, you should be able to
use the same sorting function for this as for sorting the keywords (this
will only work if you make the function generic).