lab_puzzles
Devious Dictionaries: Cleverness Through Association
|
CommonWords class. More...
#include "common_words.h"
Public Member Functions | |
CommonWords (const std::vector< std::string > &filenames) | |
Constructs a CommonWords object from a vector of filenames. More... | |
std::vector< std::string > | get_common_words (unsigned int n) const |
Private Member Functions | |
void | init_file_word_maps (const vector< string > &filenames) |
Initializes file_word_maps. More... | |
void | init_common () |
Initializes common. More... | |
vector< string > | file_to_vector (const string &filename) const |
Takes a filename and transforms it to a vector of all words in that file. More... | |
Private Attributes | |
vector< map< string, unsigned int > > | file_word_maps |
file_word_maps holds a map for each file. More... | |
std::map< std::string, unsigned int > | common |
common maps a word to the number of documents that word appears in More... | |
CommonWords class.
Definition of a class to find all the common words across multiple files
CommonWords::CommonWords | ( | const std::vector< std::string > & | filenames | ) |
Constructs a CommonWords object from a vector of filenames.
filenames | The list of filenames to read. |
n | The number of times to word has to appear. |
Initializes file_word_maps.
filenames | The vector of names of the files that will be used |
|
private |
Initializes common.
Takes a filename and transforms it to a vector of all words in that file.
filename | The name of the file that will fill the vector |
file_word_maps holds a map for each file.
Each map associates a word in that file to the number of times it has been seen in that file.
|
private |
common maps a word to the number of documents that word appears in