Bayes::HashTable Class Reference

#include <Bayes.h>

List of all members.

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)


Detailed Description

HashTable holds for each token the amount of occurences. HashTable provides functions to can be learn or un-learn given tokens.


Constructor & Destructor Documentation

Bayes::HashTable::HashTable (  ) 

The default constructor creates a new HashTable


Member Function Documentation

size_type Bayes::HashTable::getTotalWordCount (  )  const [inline]

Returns the sum of occurences of all tokens

Returns:
the total amount 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.

Parameters:
word the token whose number of occurences shall be returned
Returns:
the number of occurences of the given token

template<typename Iter>
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.

Parameters:
begin the first element in the structure that shall be learned
end the last element in the structure that shall be learned
See also:
HashTable::unlearn

HashTable::learnWord

template<typename Iter>
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.

Parameters:
begin the first element in the structure that shall be un-learned
end the last element in the structure that shall be un-learned
See also:
HashTable::learn

HashTable::unlearnWord

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.

Parameters:
word the string that shall be examined
Returns:
whether the string contains whitespaces
See also:
HashTable::m_szWhitespaces

void Bayes::HashTable::read ( std::istream &  in  ) 

This function loads the HashTable data from the given input-stream

Parameters:
in the input-stream used to load the HashTable data
See also:
HashTable::write

void Bayes::HashTable::write ( std::ostream &  out  )  const

This function stores the HashTable data to the given output-stream

Parameters:
out the output-stream used to stored the HashTable data
See also:
HashTable::read

void Bayes::HashTable::learnWord ( const std::string &  word  )  [protected]

This function is used to learn one single token.

Parameters:
word the token which shall be learned.
Note that HashTable::hasWhitespaces(word) == false must be assured when using this function.
See also:
HashTable::unlearnWord

HashTable::learn

HashTable::hasWhitespaces

void Bayes::HashTable::unlearnWord ( const std::string &  word  )  [protected]

This function is used to un-learn one single token.

Parameters:
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.
See also:
HashTable::learnWord

HashTable::unlearn

HashTable::hasWhitespaces


Member Data Documentation

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


The documentation for this class was generated from the following files:
Generated on Sat Feb 10 21:32:39 2007 for bayes-irc by  doxygen 1.5.1