#include <Bayes.h>
Public Member Functions | |
HashTable () | |
size_type | getTotalWordCount () const |
size_type | getWordCount (const std::string &word) const |
template<typename Iter> | |
void | learn (Iter begin, Iter end) |
template<typename Iter> | |
void | unlearn (Iter begin, Iter end) |
void | read (std::istream &in) |
void | write (std::ostream &out) const |
Static Public Member Functions | |
static bool | hasWhitespaces (const std::string &word) |
Protected Member Functions | |
void | learnWord (const std::string &word) |
void | unlearnWord (const std::string &word) |
Protected Attributes | |
HashMap | m_tHashMap |
size_type | m_nTotalCount |
Static Protected Attributes | |
static const char *const | m_szWhitespaces |
Friends | |
std::ostream & | operator<< (std::ostream &out, const HashTable &ht) |
Bayes::HashTable::HashTable | ( | ) |
The default constructor creates a new HashTable
size_type Bayes::HashTable::getTotalWordCount | ( | ) | const [inline] |
Returns the sum of occurences of all tokens
size_type Bayes::HashTable::getWordCount | ( | const std::string & | word | ) | const |
Returns the number of occurences in this HashTable instance of the given word.
word | the token whose number of occurences shall be returned |
void Bayes::HashTable::learn | ( | Iter | begin, | |
Iter | end | |||
) |
This function is used to learn tokens in a given iteration. HashTable::learnWord is used internally to learn each item in the iteration.
begin | the first element in the structure that shall be learned | |
end | the last element in the structure that shall be learned |
void Bayes::HashTable::unlearn | ( | Iter | begin, | |
Iter | end | |||
) |
This function is used to un-learn tokens in a given iteration. HashTable::unlearnWord is used internally to un-learn each token in the iteration.
begin | the first element in the structure that shall be un-learned | |
end | the last element in the structure that shall be un-learned |
bool Bayes::HashTable::hasWhitespaces | ( | const std::string & | word | ) | [static] |
This function returns whether a given string
contains whitespaces
so it should be split into several tokens in the learning/unlearning phase.
word | the string that shall be examined |
void Bayes::HashTable::read | ( | std::istream & | in | ) |
This function loads the HashTable data from the given input-stream
in | the input-stream used to load the HashTable data |
void Bayes::HashTable::write | ( | std::ostream & | out | ) | const |
This function stores the HashTable data to the given output-stream
out | the output-stream used to stored the HashTable data |
void Bayes::HashTable::learnWord | ( | const std::string & | word | ) | [protected] |
This function is used to learn one single token.
word | the token which shall be learned. Note that HashTable::hasWhitespaces(word) == false must be assured when using this function. |
void Bayes::HashTable::unlearnWord | ( | const std::string & | word | ) | [protected] |
This function is used to un-learn one single token.
word | the token which shall be un-learned. Note that HashTable::hasWhitespaces(word) == false must be assured when using this function and the token should have been learned beforehand. |
HashMap Bayes::HashTable::m_tHashMap [protected] |
The HashMap that holds the complete learned structure
size_type Bayes::HashTable::m_nTotalCount [protected] |
The total number of learned tokens.
const char *const Bayes::HashTable::m_szWhitespaces [static, protected] |
whitespace characters used to split up strings
(words) into tokens