Question: In this project, you are going to implement a word search engine using C++ and binary tree . The search engine would help users to

In this project, you are going to implement a word search engine using C++ and binary tree. The search engine would help users to count number of occurrence of a word among given set of text files and also sort all the words. The input specification is completely the same as first project and the program functionality is similar

The program takes as an input a set of files, containing multiple words. Words can appear multiple times in a single file or in different files.

Upon execution, the program should load all the words from the input files in the memory. The program has two modes:

Mode 1: Word search In this mode the program should run until the user explicitly specifies exit. The following functionality should be supported: 1. Count how many times a user-specified word appears in the files. 2. Display the name of input files and corresponding number of occurrences of the specified word. 3. Provide some stochastics such as: Total number of occurrences of the specified word (wordTotal) Total number of files that contain the word (fileTotal) Average number of occurrences of the specified word per file (Average)

Mode 2: Word Sorting In this mode the program should ask user to input the number of words and then print the existing words in all the input file in alphabetic order up to the input number. Upon execution of you program, you should specify as input parameter the path to a directory containing the input files.

Implementation requirements: First, you need to implement a class for an abstract data type, in which you are going to store files in memory. This step is very specific, depending on the functionality of the program you are developing. For the current implementation you are required to use Binary Tree.

You need to declare a class Word that would store a word, those properties and pointers and another class File that would store a file-name and number of times that the word occurred in this file. The process of loading files in the memory consists of (i) creating an object of type Word for each new word that occurs in the set of input files, (ii) appending this object to a binary tree and update stochastics , (iii) creating an object File for each occurrence of the word in a file and (iv) updating the corresponding (blue) linked list with the object File. Once you have the files loaded in such structure, the searching would be as easy as finding the queried word in the green binary tree and tracing in which files it occurs by going over the corresponding blue linked list.

You are required to split different aspects of this program and implement them in separate files. Then you will have to put them all back together to achieve the program functionality. You will need to create several .h and .cpp files for this project. We will help guiding you through this process. First you need to identify the important object-types and methods you will need for your implementation. In this project, your main object types are going to be class Word and class File. You can reuse your classes for File list. As before, create a file called itemtype.h and declare class File in it. Then create another file called itemtype.cpp and define your class File in it. These two files are going to be related to objects from the blue lists on the picture.

The next step is to implement the functionality for creating the blue lists. For this purpose, you need to create two more files list.h and list.cpp. In list.h declare all the methods needed for building a blue list and in list.cpp define these methods. Now, you need to implement the functionality related to objects like these in the green binary tree which is different from the first project.

Create two more files word.h and word.cpp, declare class Word and all methods to this class in word.h and define them in word.cpp. Now what's left is to put it all together by writing a main function that utilizes both file and word. To do so, create wordsearch.h and wordsearch.cpp, declare your main function in wordsearch.h and define it in wordsearch.cpp.

So all in all you will need eight files: wordsearch.h, wordsearch.cpp, itemtype.h, itemtype.cpp, list.h, list.cpp, word.h, word.cpp.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!