~/$ ./part1 Input file is: shortExample.txt Count is 12 Holla. sentences. couple a has just It example. short a is Here ~/$ ./part1 Input file is: mobyDick.txt Count is 215829 eBooks. new about hear to newsletter email our to subscribe to how and eBooks, new ... ~/$ ./part1 Input file is: asdf Error! File 'asdf' not found!
submit: ~/bin/submit -c=SI204 -p=lab11 part1.cpp
Copy your part1.cpp into part2.cpp and implement basic word search. This should allow the user to ask if words exist in the book or not, with as many searches as the user desires. 'quit' will exit the program. You must write a function which implements this search. The trick here is that we also want you to print the next word in the list after the one you found. HINT: have your search function return a pointer to the node where you found the word!
~/$ ./part2 Input file is: mobyDick.txt Count is 215829 word search: happy Word found and next word is: glad, word search: angry Word found and next word is: his word search: asdf Word not found. word search: fish Word found and next word is: murderous word search: harpoo Word not found. word search: harpoon Word found and next word is: The word search: quit!
If you do this elegantly, you'll make a new struct for
representing pairs (word,count) and make that the type of data
rather than mucking up Node with multiple data
members representing "the data". This reinforces the
fundamental idea that linked lists are the same no matter what
kind of data you put in them.
Important! This is a super inefficient way to store word counts. You have to search the entire list for each word, so your program will take 2-3 minutes to load a full novel. Test first on shortExample.txt and shortMoby.txt to make sure it works. Then run on an entire book and enjoy searching!
~/$ ./part3 Input file is: blah Error! File 'blah' not found! ~/$ ./part3 Input file is: shortMoby.txt count is 2193 word search: whale Word found with count 1 and the next word is idea word search: the Word found with count 121 and the next word is see word search: water Word found with count 4 and the next word is nigh word search: sails Word not found. word search: sail Word found with count 2 and the next word is would word search: me Word found with count 17 and the next word is Call word search: quit! ~/$ ./part3 Input file is: mobyDick.txt count is 215829 word search: whale Word found with count 393 and the next word is higgledy-piggledy word search: higgledy-piggledy Word found with count 1 and the next word is least, word search: knife Word found with count 8 and the next word is weather. word search: knot Word found with count 3 and the next word is pendulous, word search: quit!
submit: ~/bin/submit -c=SI204 -p=lab11 part1.cpp part2.cpp part3.cpp
Note: No submit for this part!
~/$ ./part4 Input file is: shortExample.txt count is 12 query: printall (Holla. 1) (sentences. 1) (couple 1) (has 1) (just 1) (It 1) (example. 1) (short 1) (a 2) (is 1) (Here 1) query: n query: n query: printall (couple 1) (has 1) (just 1) (It 1) (example. 1) (short 1) (a 2) (is 1) (Here 1) query: countall count is 10 query: n query: countall count is 9 query: sentences. Word found with count 1 and the next word is couple query: quit!
submit: ~/bin/submit -c=SI204 -p=lab11 part1.cpp part2.cpp part3.cpp part4.cpp lab11.h lab11.cpp
~/$ ./part5 Input file is: shortExample.txt count is 12 query: printall (Holla. 1) (sentences. 1) (couple 1) (has 1) (just 1) (It 1) (example. 1) (short 1) (a 2) (is 1) (Here 1) query: n query: printall (sentences. 1) (couple 1) (has 1) (just 1) (It 1) (example. 1) (short 1) (a 2) (is 1) (Here 1) query: delete It query: printall (sentences. 1) (couple 1) (has 1) (just 1) (example. 1) (short 1) (a 2) (is 1) (Here 1) query: delete Here query: printall (sentences. 1) (couple 1) (has 1) (just 1) (example. 1) (short 1) (a 2) (is 1) query: countall count is 9 query: quit!
submit: ~/bin/submit -c=SI204 -p=lab11 part1.cpp part2.cpp part3.cpp lab11.h lab11.cpp part4.cpp part5.cpp