Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 class called WordCounter that o Has 2 data members, e.g., string word, int count. o Has appropriate getters and setters o At least one constructor o Uses this keyword to help distinguish between data members and local variables Create a collection of words in such a way that your program can distinguish between different words, e.g., store each different word in an object of WordCounter class. 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 of WordCounter objects and a word to make a search of that word in that vector. If the word is found, return true else false. void incrementWordCount(????) function that counts the occurrences of the word. It is your responsibility to find out which arguments should be provided to this function. void printReport(vector &v) which 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Databases Technologies And Applications

Authors: Zongmin Ma

1st Edition

1599041219, 978-1599041216

More Books

Students also viewed these Databases questions

Question

Tell the merits and demerits of Mendeleev's periodic table.

Answered: 1 week ago

Question

What are the Five Phases of SDLC? Explain each briefly.

Answered: 1 week ago

Question

How can Change Control Procedures manage Project Creep?

Answered: 1 week ago