tyacag876 0 Newbie Poster

I'm having trouble implementing how to get it to read every word from the document and check to see if its in the dictionary using the hash table.. Please help anyone. I'm fairly new to programming.

I have to develop a spell checker program. MY program has to use a hash table to store the dictionary used by the spellchecker. My program then has to receive the name of a document and check to see if the words in the document are in the dictionary. Any words not appearing in the dictionary are assumed to be misspelled. I have to create a menu :
1) Spell Check a Document

2) Show Hash Table

3) Exit
For option 1 I have to prompt the user with the message "Document name: ". Then open the file entered by the user, read each word in the document, and find misspelled words by checking to see if each word is in the hash table (by hashing each word, not by using sequential search of the table). If there are no misspelled words, the program will produce the following output:

The spelling check is complete

If there are spelling errors, the program will produce the following output (assume carj, tge, and cburse are misspelled words in the user's file):
Mispelled words


I have created my class in a header file.


#include <iostream>
#include <cstring>
#include <fstream>

using std::string;
using namespace std;

typedef int HashElement;

class HashTable

        int hash(string word);
        a function that determines an array index for key.
        the function sums the values of the ascii codes for each letter
        in the key and returns the sum to the caller.
        void put(HashElement entry);
        places the entry into a hash table
        it uses linear probing to resolve collisions.
        HashElement get(string key);
        /*returns the element in the hash table that has the key 'string key'. 
        the record is retrieved by hashing.
        void display (int lowerbound, int upperbound);
        //prints entries between lower bound and upper bound


        string words[16000];
        //array of 16000 strings



Here is my cpp file...

#include <string>
#include <iostream>
#include <fstream>
#include "hashheader.h" 

using std::string;
using namespace std;

int main()
        string dictFilename="words.txt";
        int choice;

        cout<<"Please Choose an Option..."<<endl;
        cout<<" 1) Spell Check a Document"<<endl;
        cout<<" 2) Show Hash Table"<<endl;
        cout<<" 3) Exit"<<endl;


if(choice == 1)
ifstream fin;
char filename[49];
cout<<"Document name: "<<endl;
cin >> filename;
fin.open ("filename");


if(choice == 2)
        int lowbound;
        int upbound;

        cout<<"Enter Lower Bound: "<<endl;
        cout<<"Enter Upper Bound: "<<endl;


if(choice == 3)
        cout<<"Thank you for using my spell checker program!!"<<endl;

        //return 0;
        return 0;

system ("PAUSE");
return 0;

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.