15 static constexpr
char delimeters[] =
" \".,:;!?<>{}[]()_=+^%*&#";
16 std::string mOutputFilePath;
17 std::string mInputFilePath;
18 std::map<std::string, size_t> *mGlobalFreqencyMap;
19 std::map<std::string, size_t> mLocalFreqencyMap;
20 void addToMap(std::string word, std::map<std::string, size_t> &freqencyMap);
21 void addToMap(std::string word);
22 void parseLine(
const std::string &line);
25 Parser(
const std::string &path,
26 std::map<std::string, size_t> *globalFreqencyMap =
nullptr);
50 static void toLower(std::string &word);
53 template <
typename K,
typename V>
54 std::ostream &
operator<<(std::ostream &os,
const std::map<K, V> &m) {
55 for (
const std::pair<K, V> &p : m) {
56 os <<
"{" << p.first <<
": " << p.second <<
"}\n";
62 out << parser.mLocalFreqencyMap;
Parser class that tokenizes words and removes special characters.
Definition: parser.h:13
friend std::ostream & operator<<(std::ostream &out, const Parser &aDis)
Definition: parser.h:61
bool parse()
A function that creates a file stream from a path and parses it for word frequency.
Definition: parser.cpp:23
Parser(const std::string &path, std::map< std::string, size_t > *globalFreqencyMap=nullptr)
Initializes a Parser with an input and export file.
Definition: parser.cpp:11
void exportToFile()
A function that exports the per parser frequency map.
Definition: parser.cpp:106
StringHelper provides static helper functions to manipulate strings.
Definition: parser.h:46
static void toLower(std::string &word)
A function that lowers all characters in a string.
Definition: parser.cpp:63
std::ostream & operator<<(std::ostream &os, const std::map< K, V > &m)
Definition: parser.h:54
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
std::vector< Parser > parsers
Definition: parser.h:39
void exportGlobal(std::ostream &out=std::cout)
A function that exports the combined frequency map.
Definition: parser.cpp:119