C++!!
vector spellCheck(istream& in, const vector<:string>& dictionary, const vector& excluded) { .......
}
Part 2 - spellcheckO 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 results 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 Loop 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 ofif! found) blocks in uour code Part 2 - spellcheckO 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 results 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 Loop 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 ofif! found) blocks in uour code