ace::ContextedNGram Class Reference

Class extends NGram functionality by serving up the place to keep N-gram context within. More...

#include <ngram.h>

Inherits ace::NGram.

List of all members.

Public Member Functions

void add_to_context (const PartOfContext &part_of_context)
 Adds given part_of_context to N-gram context.
context_tcontext (void)
const context_tcontext (void) const

Static Public Member Functions

static void init (void)
 Initialize all static members which depends on value of N.

Protected Member Functions

 ContextedNGram (const raw_ngram_t &raw_ngram, ngram_type_t ngram_type)
 Raw ContextedNGram constructor.
 ContextedNGram (const NGram &source)
 "Parent-copy" constructor is allowed.
 ContextedNGram (const NGram &source, ngram_type_t ngram_type)
 "Down-cast" copy-constructor.

Static Protected Member Functions

static NGramc (const raw_ngram_t &raw_ngram, ngram_type_t ngram_type, void *mem)
 Implementation of ContextedNGram construction function.
static NGramcc (const NGram *ngram, void *mem)
 Implementation of ContextedNGram copy construction function.
static NGramdc (const NGram *ngram, ngram_type_t ngram_type, void *mem)
 Implementation of ContextedNGram downcast construction function.

Private Member Functions

 ContextedNGram (void)
 No default constructs.
 ContextedNGram (const ContextedNGram &rhs)
 No copy constructs.


Detailed Description

Class extends NGram functionality by serving up the place to keep N-gram context within.

Although this is the perfect case for use of virtualization, we do not. Use of virtualization requires additional pointer (and bytes to hold its value) to virtual methods table. We cannot afford space for this pointer, so we use static initialization and function pointers to determine, which types of N-grams are already created: NGram or ContextedNGram instances. Note, that all N-grams within single program run either have context or are context-free. The only exception is the zero typed N-gram, which is always context-free.

Definition at line 327 of file ngram.h.


Constructor & Destructor Documentation

ace::ContextedNGram::ContextedNGram ( void   )  [inline, private]

No default constructs.

ContextedNGram cannot be zero typed.

Definition at line 331 of file ngram.h.

ace::ContextedNGram::ContextedNGram ( const raw_ngram_t raw_ngram,
ngram_type_t  ngram_type 
) [protected]

Raw ContextedNGram constructor.

Calls parent raw NGram constructor and creates empty context store.

Parameters:
raw_ngram Source raw N-gram.
ngram_type Type of N-gram to be created (determines which members of `raw_ngram` are copied).

Definition at line 124 of file ngram.cpp.

ace::ContextedNGram::ContextedNGram ( const NGram source  )  [protected]

"Parent-copy" constructor is allowed.

Constructor calls its parent version and creates empty context store. Context copying is useless (the copy of ContextedNGram, which is stored within N-grams store, is enough for all purposes).

Parameters:
source NGram to be copied.

Definition at line 130 of file ngram.cpp.

ace::ContextedNGram::ContextedNGram ( const NGram source,
ngram_type_t  ngram_type 
) [protected]

"Down-cast" copy-constructor.

Constructor calls its parent version and creates empty context store. As already mention elsewhere, context copying is useless.

Parameters:
source N-gram (full type) which should be downcasted.
ngram_type Type of N-gram to be created (determines which members of `source` are copied).

Definition at line 137 of file ngram.cpp.


Member Function Documentation

static NGram* ace::ContextedNGram::c ( const raw_ngram_t raw_ngram,
ngram_type_t  ngram_type,
void *  mem 
) [inline, static, protected]

Implementation of ContextedNGram construction function.

Parameters:
mem Memory, where to create new instance (must be big enough!) See ContextedNGram(const raw_ngram_t&, ngram_type_t) constructor for other params meaning.

Reimplemented from ace::NGram.

Definition at line 341 of file ngram.h.

static NGram* ace::ContextedNGram::cc ( const NGram ngram,
void *  mem 
) [inline, static, protected]

Implementation of ContextedNGram copy construction function.

Overrides the parent version.

Parameters:
mem Memory, where to create new instance (must be big enough!) See ContextedNGram(const NGram&) constructor for other params meaning.

Reimplemented from ace::NGram.

Definition at line 349 of file ngram.h.

static NGram* ace::ContextedNGram::dc ( const NGram ngram,
ngram_type_t  ngram_type,
void *  mem 
) [inline, static, protected]

Implementation of ContextedNGram downcast construction function.

Overrides the parent version.

Parameters:
mem Memory, where to create new instance (must be big enough!) See ContextedNGram(const NGram&, ngram_type_t) constructor for other params meaning.

Reimplemented from ace::NGram.

Definition at line 357 of file ngram.h.

void ace::ContextedNGram::init ( void   )  [static]

Initialize all static members which depends on value of N.

Must be called before any ContextedNGram instance is created!

Reimplemented from ace::NGram.

Definition at line 106 of file ngram.cpp.

void ace::ContextedNGram::add_to_context ( const PartOfContext part_of_context  ) 

Adds given part_of_context to N-gram context.

Parameters:
part_of_context To be added to the N-gram context.

Definition at line 145 of file ngram.cpp.

context_t* ace::ContextedNGram::context ( void   )  [inline]

Returns:
Pointer to the context container.

Definition at line 395 of file ngram.h.

const context_t* ace::ContextedNGram::context ( void   )  const [inline]

Returns:
Pointer to the constant context container.

Definition at line 401 of file ngram.h.


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

Generated on Fri Jul 11 18:14:51 2008 for ACE by  doxygen 1.5.6