Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

HW2 Specification: As your program reads text from the file, replace every non-alphabetic character with a SPACE character; next, detect words that are separated by

image text in transcribed

HW2 Specification: As your program reads text from the file, replace every non-alphabetic character with a SPACE character; next, detect words that are separated by white-space characters; finally, convert each upper-case letter to lower-case form. For example, if the following text appears in an input file:

A test for ECE2574

Hello, hello, HELLO!

for

then the resulting bag should contain {(a, 1), (test, 1), (for, 2), (ece, 1), (hello, 3)}.

LinkedBag<:string createbagofwords inputfilename linkedbag> resultBag; // The result will be placed here, and returned std::string lineOfText; std::string inputWord; int i-; // Input stream for the file std:: ifstream iFile!; // Try to open the input file from the "build" directory iFile1.open (inputFileName); // If a file cannot be opened, notify the user and exit if (!iFile1.is_open ()) std::cerr inputword) II TO-DO: during initial debugging, use print statements to verify that correct words are being added to the bag resultBag.add (inputword); // Close the file iFile1.close() return resultBag

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

More Books

Students also viewed these Databases questions