2024-10-07 18:17:46 -06:00
|
|
|
#include "InputProcessor.h" // our custom InputProcessor class
|
2024-10-07 02:08:54 -06:00
|
|
|
#include "OutputProcessor.h" // our custom OutputProcessor class
|
|
|
|
|
2024-10-07 18:17:46 -06:00
|
|
|
#include <iostream> // for cout, endl
|
|
|
|
#include <string> // for string
|
|
|
|
#include <vector> // for vector
|
2024-10-07 02:08:54 -06:00
|
|
|
using namespace std; // so we don't have to type std:: every time
|
|
|
|
|
|
|
|
int main() {
|
2024-10-07 18:17:46 -06:00
|
|
|
// create an input processor object
|
|
|
|
InputProcessor iProcessor;
|
2024-10-07 02:08:54 -06:00
|
|
|
|
2024-10-07 18:17:46 -06:00
|
|
|
// open a stream to input from
|
|
|
|
if (!iProcessor.openStream()) {
|
|
|
|
// if stream failed to open, quit the program
|
|
|
|
cerr << "Shutting down..." << endl;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
// read the data on the stream
|
|
|
|
iProcessor.read();
|
|
|
|
// close the input stream
|
|
|
|
iProcessor.closeStream();
|
2024-10-07 02:08:54 -06:00
|
|
|
|
2024-10-07 18:17:46 -06:00
|
|
|
// retrieve all the words read from the stream
|
|
|
|
std::vector<std::string> inputWords = iProcessor.getAllWords();
|
2024-10-07 02:08:54 -06:00
|
|
|
|
2024-10-07 18:17:46 -06:00
|
|
|
// create an output processor object
|
|
|
|
OutputProcessor oProcessor;
|
|
|
|
// analyze the words and ignore the specified punctuation
|
|
|
|
oProcessor.analyzeWords(inputWords, "?!.,;:\"()_-'&[]");
|
|
|
|
// open a stream to output to
|
|
|
|
if (!oProcessor.openStream()) {
|
|
|
|
// if stream failed to open, quit the program
|
|
|
|
cerr << "Shutting down..." << endl;
|
|
|
|
return -2;
|
|
|
|
}
|
|
|
|
// write the data to the stream
|
|
|
|
oProcessor.write();
|
|
|
|
// close the output stream
|
|
|
|
oProcessor.closeStream();
|
2024-10-07 02:08:54 -06:00
|
|
|
|
2024-10-07 18:17:46 -06:00
|
|
|
// signal to user program has completed
|
|
|
|
cout << "Analysis complete, check file for results" << endl;
|
2024-10-07 02:08:54 -06:00
|
|
|
|
2024-10-07 18:17:46 -06:00
|
|
|
// end our program!
|
|
|
|
return 0;
|
2024-10-07 02:08:54 -06:00
|
|
|
}
|