Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program that checks the spelling of all words in a file. It should read

ID: 645697 • Letter: W

Question

Write a program that checks the spelling of all words in a file. It should read each word of a
file and check whether it is contained in a word list.The program should read each word of a file specified on the command line and print out all words that it cannot find in the word list. Follow this pseudo-code:

Open the dictionary file (it is called words.txt).
Define a vector of strings called words.
For each word in the dictionary file
Append the word to the words vector.
Open the file to be checked (the file is specified from the
command line)
For each word in that file
If the word is not contained in the words vector
Print the word.

Then you can create your own text file and run your program to check the words in your own created text file. Since the words in the dictionary file (named words.txt) do not contain punctuation marks, if a word in the test file is followed by a punctuation mark, it will be treated as wrong spelling. That is the reason I remove all the punctuation marks from the file named check_me.txt to simplify the spelling check. When you create your own test file, you can simply omit all the punctuation marks for the program purpose.

Explanation / Answer

#include<iostream.h>

#include<conio.h>

#include<conio.h>

#include<string.h>

#include<vector>

using namespace std;

int main()

{

vector <string> dict;

vector <string> reading;

string read,in;

string word;

cout<<"enter file to spell check : ";

cin>>read;

if stream dictionary("/usr/dict/words.text");

while(getline(dictionary,word))

{

word=word +"m";

dict.push-back(word);

}

for(int i=0;;i<dict.size();i++)

{

cout<<dict[i];

}

if stream read_in(read.c_str());

while((read_in>>in))

{

in=in+"/n";

reading.push_back(in);

}

for(int i=0;i<reading.size();i++)

{

stringout;

out=reading[i];

}

system("pause");

return 0;

}

#include<iostream.h>

#include<fstream>

using namespace std;

int main()

{

ifstream setfile("check_me.text");

string store;

while(setfile>>store)

{

for(int i=0;i<store.length();i++)

{

if (ispunct(store[i]))

{

store.erase(i,1);

}

cout<<store<<" ";

}

cout<<end;

system("pause");

return 0;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote