#ifndef SPELLING_CHECKER_H #define SPELLING_CHECKER_H #include "WordSet.h" #include "ErrorMap.h" #include "string" using namespace std; /* * SpellingChecker implements a spelling checker that may be used * to find spelling errors in text files. * A SpellingChecker is initialized with one or more dictionary files, * which define the universe of valid words. * A dictionary is loaded into a SpellingChecker using the LoadDictionary * method. * After loading the dictionarys, individual files may be spell checked * by calling the CheckDocument method. */ class SpellingChecker { private: // collection of valid words Dictionary * dictionary; // occurrences of misspelled words and their line numbers ErrorReport * errors; public: /* * No-arg constructor */ SpellingChecker(); /* * Loads the dictionary contained in the specified file * * Parameters: * filename - Name of the dictionary file to be loaded * * Returns: * true If the file was successfully loaded, false * if the file could not be loaded or was invalid */ bool LoadDictionary(const string & fileName); /* * Checks the specified document for misspelled words * * Parameters: * fileName - Name of the file to be spell checked * * Returns: * A report of misspelled words found in the document. * Each entry in the error report maps a misspelled word * to a list of line numbers where the word appears in * the file. */ ErrorReport * CheckDocument(const string & fileName); }; #endif