Question: 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

 HW2 Specification: As your program reads text from the file, replace

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

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!