#include #include #include using namespace std; #include "IOMgmt.h" using namespace IOMgmt; #include "FileParser.h" #include "Concordance.h" #include "Word.h" #include "Reference.h" int main() { try { //Indentify and Open Input File stream. InMgr finMgr("Enter ASCII Input File Name:"); ifstream& fin = finMgr.getStream(); //Prompt for Output File name and create it. OutMgr foutMgr("Enter name of Concordance Output File:"); ostream& fout = foutMgr.getStream(); //Initialize FileParser FileParser::SetFile( fin ); Word aword; Reference aref; int counter = 0; //Scan Input File for Words and their References while( FileParser::GetWordRef(fin,aword,aref) ) { /* //Debug code aword.Output(fout); aref.Output(fout); if(!(++counter % 10)) fout << endl; fout.flush(); */ //Enter the next Word and its Reference into the Concordance Concordance::AddWordRef(aword, aref); } //Issue "success" message to user. cout << "Input File Successfully Parsed! Concordance has been constructed." << endl; //Write Concordance to Output File Concordance::Output( fout ); fout << endl; fout << "-----------------------------------------------" << endl; fout << "Total Word Count = " << FileParser::GetWordcnt() << endl; fout << "Total Line Count = " << FileParser::GetLinecnt() << endl; FileParser::Reset(); finMgr.close(); foutMgr.close(); //Give "Success" message to user upon completion. cout << "Concordance has been written to Output file." << endl; return 0; } catch ( IOError e ) { //Exit on IOError when opening Input File cout << "\nError Detected Opening Input File!\n------------\n"; cout << "Description : " << e.getMsg() << endl; cout << "Origin : " << e.getOrigin() << "\n\n"; return 1; } }//main