Question: You are required to write a C++ program that would serve as a word count. Word count is used quite a lot in Natural Language

You are required to write a C++ program that would serve as a word count. Word count is used quite a lot in Natural Language Processing (NLP) and is pretty interesting concept that is used in various applications today like spam detection, sentiment analysis and etc. You are provided a text file (data.txt) with this lab which is an excerpt from Ontario Tech Universitys history. All the punctuations except the apostrophe are intentionally removed from the text. You are required to perform the following tasks: Read the text file word by word. Create a collection of words in such a way that your program can distinguish between different words, e.g., store each different word in a vector. Every time a word appears your program is required to count the occurrence of that word in the file. Finally print a report with each word and number of times it occurred in the text file provided. You can only use #include, #include, #include, include libraries. Your program should at least have the following methods: bool isFound(vector v, string word) which takes a vector and a word to make a search of that word in that vector. If the word is found, return true else false. void printReport(vector words, vector counts) which contains two vectors; one with unique words and other with count of those unique words. This method should simply have a cout statement that tells how many times a word has appeared in the file.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!