#include #include "String.h" #include "hashtable.h" // This main reads a list of dictionary words and then spells check // "Anna Karenina" by Leo Tolstoy. // We ignore all punctuation and turn everything to lower case. void main () { cout << "Loading Dictionary." << endl; hashtable dict(90000);// creates a hash table of size 90000 // you can use smaller number if you need to. ifstream ifs ("//Engr_asu/Ece352/dict.txt"); //where the dict is. String word; int count = 0; while (ifs >> word){ word.clean(); //implemented by the new String class dict.insert(word); //inserts word into hash table }; cout << "Checking Anna Karenina" << endl; hashtable badWords(10000); //creates hash table of size 10000 ifstream anna ("//Engr_asu/Ece352/anna.txt"); cout << "Starting spell check." << endl; while (anna >> word){ word.clean(); if (word == "") continue; if (!(dict.find(word))) //find returns 1 if word is found,0 if word is not found if (!(badWords.find(word))){ cout << word << " "; count++; badWords.insert(word); }; }; cout << endl << "The number of misspelled words is " << count << endl; cout << "'the' appears " << dict.getnum("the") << " times." << endl; cout << "'of' appears " << dict.getnum("of") << " times." << endl; cout << "'red' appears " << dict.getnum("red") << " times." << endl; cout << "'south' appears " << dict.getnum("south") << " times." << endl; cout << "'child' appears " << dict.getnum("child") << " times." << endl; }