#ifndef OUTPUTPROCESSOR_H #define OUTPUTPROCESSOR_H #include #include #include class OutputProcessor { public: /** * @brief Constructs a new OutputProcessor, setting internal fields to their * initial state * */ OutputProcessor(); /** * @brief Removes punctuation from the list of allWords, stores this * internally, and then computes the list of all unique words in the * original vector. In addition, it will compute the amount of occurrences * of all words in the text, and the amounts of letters in each word in the * text. * * @param allWords The vector containing all read words from the text * @param punctuation A string containing punctuation to remove from the * original vector of words */ void analyzeWords(std::vector allWords, std::string punctuation); /** * @brief Prompts the user for the filename of the file they wish to open * for outputting to, and then opens an output stream to that file * * @return true The stream was opened successfully * @return false The stream was unable to be opened successfully */ bool openStream(); /** * @brief Closes the open output stream * */ void closeStream(); /** * @brief Nicely prints the computed data to the output stream as specified * */ void write(); private: /** * @brief The output stream to write to * */ std::ofstream _fileOut; /** * @brief The list of all words with punctuation removed * */ std::vector _allWords; /** * @brief The list of all unique words, parsed from the full set * */ std::vector _uniqueWords; /** * @brief A vector containing information on how often each letter occurs in * the text. The index corresponds to the alphabetical value minus one (A is * 0, B is 1, C is 2, etc) * */ std::vector _letterCounts; /** * @brief A vector containing information on how common each unique words is * in the list of all words. The index for each word in _uniqueWords is the * same as the index for the same word in this vector. * */ std::vector _wordCounts; /** * @brief The total amount of letters in the text * */ unsigned int _totalLetterCount; /** * @brief The total amount of words in the text * */ unsigned int _totalWordCount; }; #endif // OUTPUTPROCESSOR_H