Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help with a c++ programming assignment that will finish the implementatin of a very simply (case-sensitive) spell checker. It will read in a

I need help with a c++ programming assignment that will finish the implementatin of a very simply (case-sensitive) spell checker. It will read in a dictionary file, as well as a sample text and prompt the user for corrected spellings of misspelled words. The dictionary file should be stored in a std::set, while you should store corrected spellings of known misspelled words in a std::map.

Do not rename existing function, nor add any additional functions nor member variables.

The program will read in a text file containing a list of known words (the dictionary). The program will read in a text file containing text to be checked. The program will prompt the user for the corrected spellings of any indentified words. The program will output the corrected text to the output file. The pgram will utilize the std::aet and map::libraries. The only changes will be to the spellcheck.cpp file.

main.cpp:

#include #include #include #include

#include "spellcheck.h"

int main(int argc, char** argv) { if (argc != 4) { std::cout << "Usage: assignment07 [dictionary file] [input file] [output file]" << std::endl; return 0; }

std::ifstream finDictionary(argv[1]); std::ifstream finInput(argv[2]); std::ofstream fout(argv[3]);

Spellcheck checker; checker.LoadDictionary(finDictionary); checker.Check(std::cout, std::cin, finInput, fout);

return 0; }

spellcheck.h

#ifndef __SPELLCHECK_H__ #define __SPELLCHECK_H__

#include #include #include #include

class Spellcheck { private: std::set m_Dictionary; std::map m_Replacements;

private: std::string TrimWord(std::string s) { const std::string alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; std::size_t start = s.find_first_of(alphabet); std::size_t end = s.find_last_of(alphabet); std::size_t len = end - start + 1; return s.substr(start, len); }

public: void LoadDictionary(std::istream& is); void Check(std::ostream& osInputPrompt, std::istream& isInputPrompt, std::istream& isInput, std::ostream& osOutput); };

#endif // __SPELLCHECK_H__

spellcheck.cpp

#include #include #include #include

#include "spellcheck.h"

void Spellcheck::LoadDictionary(std::istream& is) { // TODO Implement loading the dictionary }

void Spellcheck::Check(std::ostream& osInputPrompt, std::istream& isInputPrompt, std::istream& isInput, std::ostream& osOutput) { // TODO Implement a simple (case-sensitive) spell checker }

sample text:

Any elements are available at esentially the same numbr. Are elements esentially available?

smalldict.txt

ADT Assignments CS Dept Files General In Instructions Please Similarly Some The Turning We You a able all already also and anonymous another any appear are assignment at available be behaved behaviors but can complete containers data design different directory don't editor's elements encountered essentially fact for from ftp functions had however if implementation implementations in kinds least logged machine missing more must nearly need number of one operation or ordered our produce program provided read same scratch search-and-replace-all sequence sequences set sets should similar similarly spellchecker spellchecker supply than the them this to types using varied via we were with you your

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

Step: 3

blur-text-image

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

More Books

Students also viewed these Databases questions

Question

Th ey have to wait a long time for an appointment?

Answered: 1 week ago