Question: I was working on this problem and I am too lost to complete them. Can you please help me ? / / TODO: add a
I was working on this problem and I am too lost to complete them. Can you please help me TODO: add a header#include
#include
#include
#include Read all the words from the given filename, and return them as a vector
of strings.
If the file cannot be opened, return an empty vector.
std::vector ReadWordsconst std::string& filename
TODO: declare an empty vector
TODO: open a std::ifstream
TODO: write a loop that reads each word from the ifstream, and
uses pushback to add each word to the vector
TODO: return the vector
return std::vector; TODO: replace this return statement with one that actually works
Return true if word is present in dictionary, or false otherwise.
dictionary is intended to be a vector containing all words from a words.txt
file.
word is intended to be a string from a document file, that may or may not
be spelled properly.
bool InDictionaryconst std::vector& dictionary,
const std::string& word
TODO: write a linear search loop that determines whether or not
word is present in dictionary.
TODO: return true if word is present, or false otherwise
return false; TODO: replace this return statement with one that actually works
Return a vector containing all of the misspelled words in document.
dictionary is intended to be a vector containing all words from a words.txt
file.
document is intended to be a vector of all of the words from a document
file.
std::vector MisspelledWords
const std::vector& dictionary,
const std::vector& document
TODO: declare an empty vector
TODO: write a loop that checks each word string in document;
calls InDictionary to determine whether the word is in dictionary;
and adds the word to your vector if it not found
TODO: return your vector
return std::vector; TODO: replace this return statement with one that actually worksint mainint argc, char argv
std::vector argumentsargv argv argc; TODO: validate that one argument was provided.
If not, print
error: you must give a document filename
and return a nonzero exit code. TODO: store the first and only command line argument, which holds a
document filename, in a variable TODO: call ReadWords to read the contents of words.txt and store the
return value in a variable for the dictionary TODO: call ReadWords to read the contents of the document filename,
and store the return value in a variable for the document TODO: call MisspelledWords to find the list of all misspelled words, and
store the return value in a variable for the output TODO: print
spelling errors:
and then use a loop to print out each of the misspelled words return ;
The file names are:txtfox.txtleota.txtlincoln.txtwords.txtThank you.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
