Question: ( 1 ) Write the function containsWord ( 5 pt ) ( a ) Place a prototype above main ( ) under the comment /
Write the function containsWord pt
a Place a prototype above main under the comment
Add the remaining three function prototypes here
int containsWordvector words, string word;
b Write a definition for this function below main under the appropriate comment
c This function should return the index of where word is located in the vector words.
If word is not in the vector words, the function should return
d Test will test the function. You can submit after writing the function to see if it works correctly. You do not need to finish main first.
Write the function processInputFile pt
a Place a prototype above main under the comment
Add the remaining three function prototypes here
void processInputFilevector& words, vector& wordCount, ifstream& file;
b Write a definition for this function below main under the appropriate comment
c This function should read through the already opened file one word at a time.
i Each word read in should be preprocessed. For each word remove the punctuation from the word and make all the alphabetic characters lower case. You have been provided with two functions to help you with this: string removePunctuationstring word and string wordToLowerCasestring word See the comment headers for these functions to determine how to use them.
ii For each word read in the function should check if it is in the words vector
iii If it is the element at the same index in the wordCount vector should be incremented by
iv If the word is not in the words vector, it should be pushed onto the words vector and should be pushed on to the wordCount vector
d Hint: Make sure you user your containsWordremovePunctuation and wordToLowerCase
e Test will test the function. You can submit after writing the function to see if it works correctly. You do not need to finish main first.
Write the function writeOutputFile
a Place a prototype above main under the comment
Add the remaining three function prototypes here
void writeOutputFilevector words, vector wordCount, ofstream& file;
b Write a definition for this function below main under the appropriate comment
c This function should write word in the words vector along with the corresponding value from the wordCount vector separated by a space to the already opened file. Each word with it's count should be written on a separate line. The last line of the file should be the total number of words in the words vector.
Example output to the file:
the
three
little
pigs
happily
ever
Total words:
d This function will be tested with step
Finish writing the function main pt
The main function has several lines of code for you todo. Write the code to complete each TODO in main
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
