Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++!! URGENT I just need this part, ignore fileToWords function in header file that what my source code looks like; Header: Your function will return

C++!! URGENT

I just need this part, ignore fileToWords function in header file

image text in transcribed

that what my source code looks like;

image text in transcribed

Header:

image text in transcribed

Your function will return a vector of WORD structures, where each entry contains the misspelled word, along with a vector of the byte position in the file where the word was encountered. The WORD structure is defined in the header file. For instance, if the word "artcic" (a misspelling of arctic) was found three times in the input stream, there would be one entry in the returned vector, and it would contain data like this word: artic pos: 7, 95, 89 Here's the pseudocode for your function which takes an istream& and two const vector& parameters (the dictionary and the ignored words) Create the empty results vector Read until end of file (while in) Save current position (in.tellg() ->cast to long Long) If tellg() returns -1 (at end of file) Then Exit the Loop Read next word (in >> word >> ws) Convert to Lowercase, remove punctuation Search the List of misspelLed words (results)->set found If found word Then Add position to result.s ElseIf not found If found word Then ElseIf not found If found word Then (Not misspelled) ElseIf not found Go to top of loop Search the List of excLuded words-found Go to top of Loop Search the dictionary->found Go to top of Loop Create a WORD, populate with word, position Add new WORD to resuLts End Loojp Return results (misspelLed words and their positions) You can do this with a series of nested if else statements. However, the continue statement makes it quite a bit easier. The continue statement will jump back to the top of the loop, much like break jumps out of a loop. You can use continue to avoid a series of if(! found) blocks in your code Your function will return a vector of WORD structures, where each entry contains the misspelled word, along with a vector of the byte position in the file where the word was encountered. The WORD structure is defined in the header file. For instance, if the word "artcic" (a misspelling of arctic) was found three times in the input stream, there would be one entry in the returned vector, and it would contain data like this word: artic pos: 7, 95, 89 Here's the pseudocode for your function which takes an istream& and two const vector& parameters (the dictionary and the ignored words) Create the empty results vector Read until end of file (while in) Save current position (in.tellg() ->cast to long Long) If tellg() returns -1 (at end of file) Then Exit the Loop Read next word (in >> word >> ws) Convert to Lowercase, remove punctuation Search the List of misspelLed words (results)->set found If found word Then Add position to result.s ElseIf not found If found word Then ElseIf not found If found word Then (Not misspelled) ElseIf not found Go to top of loop Search the List of excLuded words-found Go to top of Loop Search the dictionary->found Go to top of Loop Create a WORD, populate with word, position Add new WORD to resuLts End Loojp Return results (misspelLed words and their positions) You can do this with a series of nested if else statements. However, the continue statement makes it quite a bit easier. The continue statement will jump back to the top of the loop, much like break jumps out of a loop. You can use continue to avoid a series of if(! found) blocks in your code

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_2

Step: 3

blur-text-image_3

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

The Temple Of Django Database Performance

Authors: Andrew Brookins

1st Edition

1734303700, 978-1734303704

More Books

Students also viewed these Databases questions

Question

Describe the impact of the Charter of Rights and Freedon1s on HRM.

Answered: 1 week ago

Question

3. How would you address the problems that make up the situation?

Answered: 1 week ago

Question

2. What recommendations will you make to the city council?

Answered: 1 week ago