Classes | Public Types | Public Member Functions | Public Attributes | List of all members
moot::mootNgrams Class Reference

Class for storage & retrieval of raw N-Gram frequencies.

Classes

class  BigramEntry
 
class  Ngram
 
class  UnigramEntry
 

Public Types

typedef CountT NgramCount
 
typedef map< mootTagString, NgramCountTrigramTable
 
typedef map< mootTagString, BigramEntryBigramTable
 
typedef map< mootTagString, UnigramEntryNgramTable
 

Public Member Functions

 mootNgrams (void)
 
 ~mootNgrams ()
 
void clear (void)
 
size_t n_unigrams (void) const
 
size_t n_bigrams (void) const
 
size_t n_trigrams (void) const
 
void add_count (const mootTagString &tag, const NgramCount count)
 
void add_count (const mootTagString &tag1, const mootTagString &tag2, const NgramCount count)
 
void add_count (const mootTagString &tag1, const mootTagString &tag2, const mootTagString &tag3, const NgramCount count)
 
void add_count (const Ngram &ngram, const NgramCount count)
 
void add_counts (const Ngram &ngram, const NgramCount count)
 
const NgramCount lookup (const mootTagString &tag) const
 
const NgramCount lookup (const mootTagString &tag1, const mootTagString &tag2) const
 
const NgramCount lookup (const mootTagString &tag1, const mootTagString &tag2, const mootTagString &tag3) const
 
bool load (const char *filename)
 
bool load (FILE *file, const char *filename=__null)
 
bool save (const char *filename, bool compact=false)
 
bool save (FILE *file, const char *filename=__null, bool compact=false)
 

Public Attributes

NgramTable ngtable
 
NgramCount ugtotal
 

Member Typedef Documentation

◆ NgramCount

Type for an N-Gram count

◆ TrigramTable

Type for tertiary (tag->trigramCount) lookup-table entry

◆ BigramTable

Type for secondary lookup table

◆ NgramTable

Type for primary lookup-table

Constructor & Destructor Documentation

◆ mootNgrams()

moot::mootNgrams::mootNgrams ( void  )
inline

Default constructor

◆ ~mootNgrams()

moot::mootNgrams::~mootNgrams ( )
inline

Default destructor

References clear().

Member Function Documentation

◆ clear()

void moot::mootNgrams::clear ( void  )
inline

◆ n_unigrams()

size_t moot::mootNgrams::n_unigrams ( void  ) const
inline

Return the number of distinct stored unigrams

References n_bigrams(), and n_trigrams().

◆ n_bigrams()

size_t moot::mootNgrams::n_bigrams ( void  ) const

Return the number of distinct stored bigrams

Referenced by n_unigrams().

◆ n_trigrams()

size_t moot::mootNgrams::n_trigrams ( void  ) const

Return the number of distinct stored trigrams

Referenced by n_unigrams().

◆ add_count() [1/4]

void moot::mootNgrams::add_count ( const mootTagString tag,
const NgramCount  count 
)
inline

Add count to the current count for unigram <tag>.

References moot::mootNgrams::BigramEntry::count.

Referenced by add_count().

◆ add_count() [2/4]

void moot::mootNgrams::add_count ( const mootTagString tag1,
const mootTagString tag2,
const NgramCount  count 
)
inline

Add count to the current count for bigram <tag1, tag2> Does NOT add any unigram counts.

References moot::mootNgrams::BigramEntry::count.

◆ add_count() [3/4]

void moot::mootNgrams::add_count ( const mootTagString tag1,
const mootTagString tag2,
const mootTagString tag3,
const NgramCount  count 
)
inline

Add count to the current count for trigram <tag1, tag2, tag3> Does NOT add any bigram or unigram counts.

References moot::mootNgrams::BigramEntry::count.

◆ add_count() [4/4]

void moot::mootNgrams::add_count ( const Ngram ngram,
const NgramCount  count 
)
inline

Add count to the current count for ngram – length-dependent.

References add_count(), and moot::mootNgrams::BigramEntry::count.

◆ add_counts()

void moot::mootNgrams::add_counts ( const Ngram ngram,
const NgramCount  count 
)
inline

Add count to the current count for <tag1>, <tag1,tag2>, and <tag1,tag2,tag3> in ngram.... ngram may be shorter than 3 tags, in which case counts are only added for the elements present.

References moot::mootNgrams::BigramEntry::BigramEntry(), moot::mootNgrams::BigramEntry::count, moot::mootNgrams::Ngram::tag1(), moot::mootNgrams::Ngram::tag2(), and moot::mootNgrams::Ngram::tag3().

◆ lookup() [1/3]

const NgramCount moot::mootNgrams::lookup ( const mootTagString tag) const
inline

Returns current count for unigram, returns 0 if unknown

◆ lookup() [2/3]

const NgramCount moot::mootNgrams::lookup ( const mootTagString tag1,
const mootTagString tag2 
) const
inline

Returns current count for bigram <tag1,tag2>, returns 0 if unknown

◆ lookup() [3/3]

const NgramCount moot::mootNgrams::lookup ( const mootTagString tag1,
const mootTagString tag2,
const mootTagString tag3 
) const
inline

Returns current count for trigram <tag1,tag2,tag3>, returns 0 if unknown

References load(), and save().

◆ load() [1/2]

bool moot::mootNgrams::load ( const char *  filename)

Load n-grams from a TnT-style parameter file

Referenced by lookup().

◆ load() [2/2]

bool moot::mootNgrams::load ( FILE *  file,
const char *  filename = __null 
)

Load n-grams from a TnT-style parameter file (stream version)

◆ save() [1/2]

bool moot::mootNgrams::save ( const char *  filename,
bool  compact = false 
)

Save n-grams to a TnT-style paramater file

Referenced by lookup().

◆ save() [2/2]

bool moot::mootNgrams::save ( FILE *  file,
const char *  filename = __null,
bool  compact = false 
)

Save n-grams to a TnT-style paramater file (stream version)

Member Data Documentation

◆ ngtable

NgramTable moot::mootNgrams::ngtable

N-Gram to count lookup table

◆ ugtotal

NgramCount moot::mootNgrams::ugtotal

total number of unigrams


The documentation for this class was generated from the following file: