WordFreq
WordFreq Overview

Introduction to WordFreq

The WordFreq module supports the parsing and sorting alphabetically words in a text file. The primary use case is to collect word frequency information locally per document aswell as across multiple documents.


WordFreq Classes

  • Parser - A class that parses and stores word frequency analytics.
  • ParserCollection - A class that holds collection types needed to parse multiple files.
  • StringHelper - A class that provides common string operations like lowering characters.


Example Usage - parse a file and export the analytics.

#include <iostream>
#include "lib/parser.h"
int main() {
std::string fileName;
std::cout << "Please enter a file name: ";
std::cin >> fileName;
Parser parser(fileName);
parser.parse();
parser.exportToFile();
return 0;
}
Parser class that tokenizes words and removes special characters.
Definition: parser.h:13


Example Usage - parse multiple file and export the combinded analytics.

#include <iostream>
#include "lib/parser.h"
int main() {
ParserCollection parserCollection;
std::string fileName;
for(int i = 0; i < 3; i++) {
std::cout << "Please enter a file name: ";
std::cin >> fileName;
Parser parser(fileName, &parserCollection.globalFreqencyMap);
parser.parse();
}
parserCollection.exportGlobal();
return 0;
}
Common data structures needed to support cross file frequency analysis.
Definition: parser.h:37
std::map< std::string, size_t > globalFreqencyMap
Definition: parser.h:38
void exportGlobal(std::ostream &out=std::cout)
A function that exports the combined frequency map.
Definition: parser.cpp:119