A3/main.cpp

47 lines
1.3 KiB
C++
Raw Permalink Normal View History

#include "InputProcessor.h" // our custom InputProcessor class
2024-10-07 02:08:54 -06:00
#include "OutputProcessor.h" // our custom OutputProcessor class
#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() {
// create an input processor object
InputProcessor iProcessor;
2024-10-07 02:08:54 -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
// retrieve all the words read from the stream
std::vector<std::string> inputWords = iProcessor.getAllWords();
2024-10-07 02:08:54 -06:00
// create an output processor object
OutputProcessor oProcessor;
// analyze the words and ignore the specified punctuation
2024-10-09 17:20:26 -06:00
oProcessor.analyzeWords(inputWords, "?!.,;:\"()_-'&[]\\/1234567890@");
// 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
// signal to user program has completed
cout << "Analysis complete, check file for results" << endl;
2024-10-07 02:08:54 -06:00
// end our program!
return 0;
2024-10-07 02:08:54 -06:00
}