#include <util.H>
Public Member Functions | |
NGramCounter () | |
Ctor; initializes object to be empty. | |
void | write (ostream &outStrm, const SymbolTable &symTable=SymbolTable()) const |
Writes all counts to stream outStrm in a text format. | |
void | clear () |
Clears object; deletes all n-grams in table. | |
unsigned | size () const |
Returns number of n-grams in table. | |
bool | empty () const |
Returns whether object is empty. | |
unsigned | incr_count (const vector< int > &ngram) |
Increments count of an n-gram; returns new count. | |
void | set_count (const vector< int > &ngram, unsigned val) |
Sets count of an n-gram to val . | |
unsigned | get_count (const vector< int > &ngram) const |
Returns count of an n-gram, or 0 if not present. |
N-grams are represented as vectors of integers. The main access methods are incr_count(), set_count(), and get_count().
NGramCounter::NGramCounter | ( | ) | [inline] |
Ctor; initializes object to be empty.
void NGramCounter::write | ( | ostream & | outStrm, | |
const SymbolTable & | symTable = SymbolTable() | |||
) | const |
Writes all counts to stream outStrm
in a text format.
Uses symTable
to map integer indices to strings, if present.
void NGramCounter::clear | ( | ) | [inline] |
Clears object; deletes all n-grams in table.
unsigned NGramCounter::size | ( | ) | const [inline] |
Returns number of n-grams in table.
bool NGramCounter::empty | ( | ) | const [inline] |
Returns whether object is empty.
unsigned NGramCounter::incr_count | ( | const vector< int > & | ngram | ) | [inline] |
Increments count of an n-gram; returns new count.
void NGramCounter::set_count | ( | const vector< int > & | ngram, | |
unsigned | val | |||
) | [inline] |
Sets count of an n-gram to val
.
If val
is 0, n-gram is removed from table.
unsigned NGramCounter::get_count | ( | const vector< int > & | ngram | ) | const [inline] |
Returns count of an n-gram, or 0 if not present.