Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

2) Software - EBook Summarizer: An eBook company has hired you to write a progra

ID: 3911782 • Letter: 2

Question

2) Software - EBook Summarizer: An eBook company has hired you to write a program to help them to organize their books by their contents. Your program must read a text file of a book and learn the most common words that book contains. Given that the intent of this program is to understand the books' core topics, your list of words in the book should exclude common words like: and, but, he, she, it, etc. that don't help to understand what the book is about. Your program should output a summary of words that the book contains. Your code is expected to be efficient and well commented.

Explanation / Answer

/* The list of words to be ignored can be bigger.The list of words
   to be ignored can be in another file beacuse the number of words
   may be very high to be hardcoded in the program.So the program will
   read that file and besides outputing the relevant words on the console
   will also output the summary words in a file.

*/


#include<iostream>
#include<string>
#include<sstream>
#include<fstream>

using namespace std;


int main(){

     string ignored[1000];

     ifstream fin1("ignored.txt");
     if (!fin1){
         cout << "Error opening file ";
         return 0;
     }
     int count = 0;
     while(fin1 >> ignored[count])
          count++;

     ifstream fin2("Book.txt");
     if (!fin2){
         cout << "Error opening file ";
         return 0;
     }
     string word;   
    
     ofstream fout("summary.txt");
     while(fin2 >> word){
         int found = 0;
         for (int i = 0; i<count; i++){
             if (ignored[i] == word){
                 found = 1;
                 break;
             }
         }
         if (found == 0){
             cout << word << endl;
             fout << word << endl;
         }
     }
     fin2.close();
     fout.close();
     return 0;

    
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote