sampleMainP3.cpp

// Computing Structures CS/DSA 5005 Fall 2019 // Project 3 // Sample Main and Class definition // Author: Aditya Narasimhan #include<iostream> #include<vector> // used in the class for storing the bash buckets only #include<string> // used for all string manipulations #include<fstream> // used for reading the documents only #include<math.h> // used for finding the log in idf only using namespace std; // Class Hash class Hash { // ostream operator to display the has table protected: int buckets; // Number of buckets in vector<string> *table; // hash table public: Hash(); // default constructor Hash(int v); // non-default constructor void insertItem(int index, string w); // to insert item to the hash table void displayHash(); // to display the has table(same as the ostream) int wordExistent(string check); // rerurn 1 if the word is existent in the hash table int findKey(string check); // given a string, return the key void findValue(int keyToFind); // given a key, return the value/string }; int main() { // TODO: // get the numberOfDocuments as redirected input from the input file cout << "The number of documents: " << numberOfDocuments << endl; // insert the keys into the hash table Hash* h = new Hash[numberOfDocuments]; // 20 is count of buckets in // hash table // TODO: // declare an array of objects(h[]) of class hash of length numberOfDocuments int * numWords = new int[numberOfDocuments]; // used to store the words that are read from the document // TODO: // input the all the document names to be opened and the corresponding word count in each of them // count the number of occurances(key) of each word in the document and store it to the hash table of the corresponding hash object // display the Hash table for(int i = 0; i < numberOfDocuments; i++) { cout << "Hash table for doc" << i+1 << ".txt" << endl; cout << h[i]; // ostream overloaded cout << endl; } // TODO: // input the string for which we need to find the number of occurances across all documents // display the result if(...) cout << "The key/frequency of the word '" ... else cout << "The word was not found!" << endl; // TODO: // input the key for which the strings are to be displayed - format to be viewed in the sample output file // Term Frequency // TODO: // input the string and the document for which we need to find the tf //Inverse Document Frequency // TODO: // input the string for which we need to find the idf return 0; }