ngramtable Class Reference

#include <ngramtable.h>

Inheritance diagram for ngramtable:

Inheritance graph
[legend]
Collaboration diagram for ngramtable:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 ngramtable (char *filename, int maxl, char *is, char *oovlex, char *filterdictfile, int googletable=0, int dstco=0, char *hmask=NULL, int inplen=0, TABLETYPE tt=FULL, int codesize=DEFCODESIZE)
char * ngtype (char *str=NULL)
 ~ngramtable ()
void freetree (node nd)
void stat (int level=4)
long long totfreq (long long v=-1)
long long btotfreq (long long v=-1)
long long entries (int lev)
int maxlevel ()
void savetxt (char *filename, int sz=0, int googleformat=0)
void loadtxt (char *filename, int googletable=0)
void savebin (char *filename, int sz=0)
void savebin (mfstream &out)
void savebin (mfstream &out, node nd, NODETYPE ndt, int lev, int mlev)
void loadbin (const char *filename)
void loadbin (mfstream &inp)
void loadbin (mfstream &inp, node nd, NODETYPE ndt, int lev)
void loadbinold (char *filename)
void loadbinold (mfstream &inp, node nd, NODETYPE ndt, int lev)
void generate (char *filename)
void generate_dstco (char *filename, int dstco)
void generate_hmask (char *filename, char *hmask, int inplen=0)
void augment (ngramtable *ngt)
int scan (ngram &ng, ACTION action=CONT, int maxlev=-1)
int succscan (ngram &h, ngram &ng, ACTION action, int lev)
double prob (ngram ng)
int scan (node nd, NODETYPE ndt, int lev, ngram &ng, ACTION action=CONT, int maxl=-1)
void show ()
void * search (table *tb, NODETYPE ndt, int lev, int n, int sz, int *w, ACTION action, char **found=(char **) NULL)
int mybsearch (char *ar, int n, int size, unsigned char *key, int *idx)
int put (ngram &ng)
int put (ngram &ng, node nd, NODETYPE ndt, int lev)
int get (ngram &ng)
int get (ngram &ng, int n, int lev)
int comptbsize (int n)
tablegrow (table *tb, NODETYPE ndt, int lev, int n, int sz, NODETYPE oldndt=0)
int putmem (char *ptr, int value, int offs, int size)
int getmem (char *ptr, int *value, int offs, int size)
long putmem (char *ptr, long long value, int offs, int size)
long getmem (char *ptr, long long *value, int offs, int size)
void tb2ngcpy (int *wordp, char *tablep, int n=1)
void ng2tbcpy (char *tablep, int *wordp, int n=1)
int ngtbcmp (int *wordp, char *tablep, int n=1)
int word (node nd, int value)
int word (node nd)
unsigned char mtflags (node nd, unsigned char value)
unsigned char mtflags (node nd)
int update (ngram ng)
long long freq (node nd, NODETYPE ndt, long long value)
long long freq (node nd, NODETYPE ndt)
long long setfreq (node nd, NODETYPE ndt, long long value, int index=0)
long long getfreq (node nd, NODETYPE ndt, int index=0)
double boff (node nd)
double myround (double x)
int boff (node nd, double value)
int succ2 (node nd, int value)
int succ2 (node nd)
int succ1 (node nd, int value)
int succ1 (node nd)
int msucc (node nd, int value)
int msucc (node nd)
table mtable (node nd)
table mtable (node nd, table value)
int mtablesz (node nd)
int bo_state (int value=-1)

Public Attributes

int corrcounts
dictionarydict
dictionaryfilterdict


Detailed Description

Definition at line 296 of file ngramtable.h.


Constructor & Destructor Documentation

ngramtable::ngramtable ( char *  filename,
int  maxl,
char *  is,
char *  oovlex,
char *  filterdictfile,
int  googletable = 0,
int  dstco = 0,
char *  hmask = NULL,
int  inplen = 0,
TABLETYPE  tt = FULL,
int  codesize = DEFCODESIZE 
)

ngramtable::~ngramtable (  ) 

Definition at line 1343 of file ngramtable.cpp.

References dict, and freetree().

Here is the call graph for this function:


Member Function Documentation

void ngramtable::augment ( ngramtable ngt  ) 

Definition at line 697 of file ngramtable.cpp.

References CONT, dictionary::decode(), dict, dictionary::encode(), dictionary::freq(), dictionary::getcode(), dictionary::incflag(), dictionary::incfreq(), INIT, dictionary::OOV(), dictionary::oovcode(), put(), scan(), dictionary::size(), and ngram::trans().

Referenced by main(), and mixture::mixture().

Here is the call graph for this function:

Here is the caller graph for this function:

int ngramtable::bo_state ( int  value = -1  )  [inline]

Definition at line 680 of file ngramtable.h.

Referenced by main(), and prob().

Here is the caller graph for this function:

int ngramtable::boff ( node  nd,
double  value 
) [inline]

Definition at line 583 of file ngramtable.h.

References tabletype::BOFF_OFFS, INTSIZE, myround(), and putmem().

Here is the call graph for this function:

double ngramtable::boff ( node  nd  )  [inline]

Definition at line 569 of file ngramtable.h.

References tabletype::BOFF_OFFS, getmem(), and INTSIZE.

Referenced by mdiadaptlm::bodiscount(), mdiadaptlm::compute_backoff(), and mdiadaptlm::saveASR().

Here is the call graph for this function:

Here is the caller graph for this function:

long long ngramtable::btotfreq ( long long  v = -1  )  [inline]

Definition at line 349 of file ngramtable.h.

References getfreq(), and setfreq().

Referenced by mshiftbeta::discount(), and interplm::gencorrcounts().

Here is the call graph for this function:

Here is the caller graph for this function:

int ngramtable::comptbsize ( int  n  ) 

Definition at line 886 of file ngramtable.cpp.

Referenced by freetree(), and grow().

Here is the caller graph for this function:

long long ngramtable::entries ( int  lev  )  [inline]

Definition at line 353 of file ngramtable.h.

Referenced by symshiftbeta::discount().

Here is the caller graph for this function:

void ngramtable::freetree ( node  nd  ) 

Definition at line 1328 of file ngramtable.cpp.

References comptbsize(), storage::free(), INODE, msucc(), mtable(), mtablesz(), and mtflags().

Referenced by ~ngramtable().

Here is the call graph for this function:

Here is the caller graph for this function:

long long ngramtable::freq ( node  nd,
NODETYPE  ndt 
) [inline]

Definition at line 510 of file ngramtable.h.

References FREQ1, FREQ2, FREQ3, FREQ4, getmem(), tabletype::I_FREQ_OFFS, tabletype::L_FREQ_OFFS, and LNODE.

Here is the call graph for this function:

long long ngramtable::freq ( node  nd,
NODETYPE  ndt,
long long  value 
) [inline]

Definition at line 493 of file ngramtable.h.

References FREQ1, FREQ2, FREQ3, FREQ4, tabletype::I_FREQ_OFFS, tabletype::L_FREQ_OFFS, LNODE, and putmem().

Referenced by interplm::gencorrcounts(), get(), ngramtable(), put(), scan(), totfreq(), mdiadaptlm::txclprob(), and update().

Here is the call graph for this function:

Here is the caller graph for this function:

void ngramtable::generate ( char *  filename  ) 

void ngramtable::generate_dstco ( char *  filename,
int  dstco 
)

Definition at line 596 of file ngramtable.cpp.

References mfstream::close(), cmpint(), tabletype::code_range, tabletype::CODESIZE, dict, ngram::freq, dictionary::incflag(), dictionary::incfreq(), MAX_NGRAM, put(), dictionary::size(), ngram::size, ngram::trans(), and ngram::wordp().

Referenced by ngramtable().

Here is the call graph for this function:

Here is the caller graph for this function:

void ngramtable::generate_hmask ( char *  filename,
char *  hmask,
int  inplen = 0 
)

Definition at line 530 of file ngramtable.cpp.

References mfstream::close(), tabletype::code_range, tabletype::CODESIZE, dict, dictionary::incflag(), dictionary::incfreq(), MAX_NGRAM, put(), dictionary::size(), ngram::size, ngram::trans(), and ngram::wordp().

Referenced by ngramtable().

Here is the call graph for this function:

Here is the caller graph for this function:

int ngramtable::get ( ngram ng,
int  n,
int  lev 
)

int ngramtable::get ( ngram ng  )  [inline]

Definition at line 403 of file ngramtable.h.

Referenced by normcache::get(), main(), and normcache::put().

Here is the caller graph for this function:

long long ngramtable::getfreq ( node  nd,
NODETYPE  ndt,
int  index = 0 
) [inline]

Definition at line 548 of file ngramtable.h.

References FREQ1, FREQ2, FREQ3, FREQ4, getmem(), tabletype::I_FREQ_OFFS, tabletype::L_FREQ_OFFS, and LNODE.

Referenced by btotfreq(), interplm::gencorrcounts(), interplm::gensuccstat(), grow(), and mshiftbeta::mfreq().

Here is the call graph for this function:

Here is the caller graph for this function:

long ngramtable::getmem ( char *  ptr,
long long *  value,
int  offs,
int  size 
) [inline]

Definition at line 431 of file ngramtable.h.

References NULL.

int ngramtable::getmem ( char *  ptr,
int *  value,
int  offs,
int  size 
) [inline]

Definition at line 416 of file ngramtable.h.

References NULL.

Referenced by boff(), freq(), getfreq(), msucc(), ngtbcmp(), succ1(), succ2(), tb2ngcpy(), and word().

Here is the caller graph for this function:

char ** ngramtable::grow ( table tb,
NODETYPE  ndt,
int  lev,
int  n,
int  sz,
NODETYPE  oldndt = 0 
)

Definition at line 909 of file ngramtable.cpp.

References storage::allocate(), comptbsize(), storage::free(), FREQ1, FREQ2, FREQ3, FREQ4, getfreq(), tabletype::I_FREQ_NUM, INODE, tabletype::inodesize(), tabletype::L_FREQ_NUM, LNODE, tabletype::lnodesize(), msucc(), mtable(), mtflags(), NULL, storage::reallocate(), setfreq(), and word().

Referenced by loadbin(), put(), and search().

Here is the call graph for this function:

Here is the caller graph for this function:

void ngramtable::loadbin ( mfstream inp,
node  nd,
NODETYPE  ndt,
int  lev 
)

void ngramtable::loadbin ( mfstream inp  ) 

Definition at line 424 of file ngramtable.cpp.

References CHARSIZE, INTSIZE, loadbin(), and mfstream::readx().

Here is the call graph for this function:

void ngramtable::loadbin ( const char *  filename  ) 

Definition at line 437 of file ngramtable.cpp.

References CHARSIZE, mfstream::close(), dict, INTSIZE, dictionary::load(), and mfstream::readx().

Referenced by loadbin(), and ngramtable().

Here is the call graph for this function:

Here is the caller graph for this function:

void ngramtable::loadbinold ( mfstream inp,
node  nd,
NODETYPE  ndt,
int  lev 
)

void ngramtable::loadbinold ( char *  filename  ) 

void ngramtable::loadtxt ( char *  filename,
int  googletable = 0 
)

Definition at line 216 of file ngramtable.cpp.

References dictionary::decode(), dict, dictionary::encode(), filterdict, ngram::freq, dictionary::incflag(), dictionary::load(), dictionary::oovcode(), and put().

Referenced by ngramtable().

Here is the call graph for this function:

Here is the caller graph for this function:

int ngramtable::maxlevel (  )  [inline]

Definition at line 357 of file ngramtable.h.

Referenced by mshiftbeta::discount(), interplm::gencorrcounts(), interplm::interplm(), main(), mdiadaptlm::netsize(), mdiadaptlm::saveMT(), and interplm::test_ngt().

Here is the caller graph for this function:

int ngramtable::msucc ( node  nd  )  [inline]

Definition at line 623 of file ngramtable.h.

References tabletype::CODESIZE, getmem(), and tabletype::MSUCC_OFFS.

Here is the call graph for this function:

int ngramtable::msucc ( node  nd,
int  value 
) [inline]

Definition at line 617 of file ngramtable.h.

References tabletype::CODESIZE, tabletype::MSUCC_OFFS, and putmem().

Referenced by freetree(), get(), grow(), loadbin(), ngramtable(), put(), savebin(), and scan().

Here is the call graph for this function:

Here is the caller graph for this function:

table ngramtable::mtable ( node  nd,
table  value 
) [inline]

Definition at line 639 of file ngramtable.h.

References tabletype::MTAB_OFFS, and PTRSIZE.

table ngramtable::mtable ( node  nd  )  [inline]

Definition at line 630 of file ngramtable.h.

References tabletype::MTAB_OFFS, and PTRSIZE.

Referenced by freetree(), get(), grow(), loadbin(), ngramtable(), put(), savebin(), and scan().

Here is the caller graph for this function:

int ngramtable::mtablesz ( node  nd  )  [inline]

Definition at line 647 of file ngramtable.h.

References FREQ1, FREQ2, FREQ3, FREQ4, INODE, tabletype::inodesize(), LNODE, tabletype::lnodesize(), and mtflags().

Referenced by freetree(), get(), loadbin(), put(), savebin(), and scan().

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned char ngramtable::mtflags ( node  nd  )  [inline]

Definition at line 475 of file ngramtable.h.

References tabletype::FLAGS_OFFS.

unsigned char ngramtable::mtflags ( node  nd,
unsigned char  value 
) [inline]

Definition at line 471 of file ngramtable.h.

References tabletype::FLAGS_OFFS.

Referenced by freetree(), get(), grow(), loadbin(), mtablesz(), ngramtable(), put(), savebin(), and scan().

Here is the caller graph for this function:

int ngramtable::mybsearch ( char *  ar,
int  n,
int  size,
unsigned char *  key,
int *  idx 
)

Definition at line 755 of file ngramtable.cpp.

References tabletype::CODESIZE, and NULL.

Referenced by search().

Here is the caller graph for this function:

double ngramtable::myround ( double  x  )  [inline]

Reimplemented in mdiadaptlm.

Definition at line 578 of file ngramtable.h.

Referenced by boff().

Here is the caller graph for this function:

void ngramtable::ng2tbcpy ( char *  tablep,
int *  wordp,
int  n = 1 
) [inline]

Definition at line 444 of file ngramtable.h.

References tabletype::CODESIZE, and putmem().

Here is the call graph for this function:

int ngramtable::ngtbcmp ( int *  wordp,
char *  tablep,
int  n = 1 
) [inline]

Definition at line 449 of file ngramtable.h.

References tabletype::CODESIZE, getmem(), and word().

Here is the call graph for this function:

char* ngramtable::ngtype ( char *  str = NULL  )  [inline]

Definition at line 339 of file ngramtable.h.

References NULL.

Referenced by main().

Here is the caller graph for this function:

double ngramtable::prob ( ngram  ng  ) 

Definition at line 1384 of file ngramtable.cpp.

References bo_state(), dict, ngram::freq, LEAFPROB, ngram::size, tabletype::tbtype(), ngram::trans(), and ngram::wordp().

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:

int ngramtable::put ( ngram ng,
node  nd,
NODETYPE  ndt,
int  lev 
)

Definition at line 1053 of file ngramtable.cpp.

References ENTER, FIND, ngram::freq, freq(), FREQ1, FREQ2, FREQ3, FREQ4, FREQ6, grow(), tabletype::I_FREQ_NUM, INODE, tabletype::L_FREQ_SIZE, LNODE, msucc(), mtable(), mtablesz(), mtflags(), search(), ngram::size, and ngram::wordp().

Here is the call graph for this function:

int ngramtable::put ( ngram ng  ) 

Definition at line 1047 of file ngramtable.cpp.

Referenced by augment(), interplm::gencorrcounts(), generate(), generate_dstco(), generate_hmask(), loadtxt(), main(), normcache::put(), and mdiadaptlm::saveMT().

Here is the caller graph for this function:

long ngramtable::putmem ( char *  ptr,
long long  value,
int  offs,
int  size 
) [inline]

Definition at line 424 of file ngramtable.h.

References NULL.

int ngramtable::putmem ( char *  ptr,
int  value,
int  offs,
int  size 
) [inline]

Definition at line 409 of file ngramtable.h.

References NULL.

Referenced by boff(), freq(), msucc(), ng2tbcpy(), search(), setfreq(), succ1(), succ2(), and word().

Here is the caller graph for this function:

void ngramtable::savebin ( mfstream out,
node  nd,
NODETYPE  ndt,
int  lev,
int  mlev 
)

void ngramtable::savebin ( mfstream out  ) 

Definition at line 314 of file ngramtable.cpp.

References CHARSIZE, INTSIZE, savebin(), and mfstream::writex().

Here is the call graph for this function:

void ngramtable::savebin ( char *  filename,
int  sz = 0 
)

Reimplemented in interplm.

Definition at line 332 of file ngramtable.cpp.

References CHARSIZE, mfstream::close(), dict, INTSIZE, dictionary::oovcode(), dictionary::save(), and mfstream::writex().

Referenced by main(), and savebin().

Here is the call graph for this function:

Here is the caller graph for this function:

void ngramtable::savetxt ( char *  filename,
int  sz = 0,
int  googleformat = 0 
)

Definition at line 180 of file ngramtable.cpp.

References mfstream::close(), CONT, dict, INIT, dictionary::save(), and scan().

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:

int ngramtable::scan ( node  nd,
NODETYPE  ndt,
int  lev,
ngram ng,
ACTION  action = CONT,
int  maxl = -1 
)

int ngramtable::scan ( ngram ng,
ACTION  action = CONT,
int  maxlev = -1 
) [inline]

void * ngramtable::search ( table tb,
NODETYPE  ndt,
int  lev,
int  n,
int  sz,
int *  w,
ACTION  action,
char **  found = (char **)NULL 
)

Definition at line 793 of file ngramtable.cpp.

References tabletype::CODESIZE, DELETE, ENTER, FIND, grow(), mybsearch(), NULL, putmem(), and word().

Referenced by get(), and put().

Here is the call graph for this function:

Here is the caller graph for this function:

long long ngramtable::setfreq ( node  nd,
NODETYPE  ndt,
long long  value,
int  index = 0 
) [inline]

Definition at line 530 of file ngramtable.h.

References FREQ1, FREQ2, FREQ3, FREQ4, tabletype::I_FREQ_OFFS, tabletype::L_FREQ_OFFS, LNODE, and putmem().

Referenced by btotfreq(), interplm::gencorrcounts(), and grow().

Here is the call graph for this function:

Here is the caller graph for this function:

void ngramtable::show (  ) 

Definition at line 743 of file ngramtable.cpp.

References dict, INIT, and scan().

Here is the call graph for this function:

void ngramtable::stat ( int  level = 4  ) 

Definition at line 1353 of file ngramtable.cpp.

References dict, storage::stat(), and dictionary::stat().

Referenced by interplm::lmstat(), and main().

Here is the call graph for this function:

Here is the caller graph for this function:

int ngramtable::succ1 ( node  nd  )  [inline]

Definition at line 610 of file ngramtable.h.

References tabletype::CODESIZE, getmem(), and tabletype::SUCC1_OFFS.

Here is the call graph for this function:

int ngramtable::succ1 ( node  nd,
int  value 
) [inline]

Definition at line 604 of file ngramtable.h.

References tabletype::CODESIZE, putmem(), and tabletype::SUCC1_OFFS.

Referenced by mshiftbeta::discount(), shiftbeta::discount(), linearwb::discount(), interplm::gensuccstat(), mdiadaptlm::saveASR(), and shiftbeta::train().

Here is the call graph for this function:

Here is the caller graph for this function:

int ngramtable::succ2 ( node  nd  )  [inline]

Definition at line 597 of file ngramtable.h.

References tabletype::CODESIZE, getmem(), and tabletype::SUCC2_OFFS.

Here is the call graph for this function:

int ngramtable::succ2 ( node  nd,
int  value 
) [inline]

Definition at line 591 of file ngramtable.h.

References tabletype::CODESIZE, putmem(), and tabletype::SUCC2_OFFS.

Referenced by mshiftbeta::discount(), interplm::gensuccstat(), and mdiadaptlm::saveASR().

Here is the call graph for this function:

Here is the caller graph for this function:

int ngramtable::succscan ( ngram h,
ngram ng,
ACTION  action,
int  lev 
) [inline]

Definition at line 384 of file ngramtable.h.

References ngram::info, ngram::link, and scan().

Referenced by mdiadaptlm::compute_backoff(), interplm::gensuccstat(), mdiadaptlm::saveASR(), shiftbeta::train(), and mdiadaptlm::zeta().

Here is the call graph for this function:

Here is the caller graph for this function:

void ngramtable::tb2ngcpy ( int *  wordp,
char *  tablep,
int  n = 1 
) [inline]

Definition at line 439 of file ngramtable.h.

References tabletype::CODESIZE, and getmem().

Here is the call graph for this function:

long long ngramtable::totfreq ( long long  v = -1  )  [inline]

Definition at line 345 of file ngramtable.h.

References freq(), and INODE.

Referenced by symshiftbeta::discount(), mshiftbeta::discount(), and mdiadaptlm::txclprob().

Here is the call graph for this function:

Here is the caller graph for this function:

int ngramtable::update ( ngram  ng  )  [inline]

Definition at line 480 of file ngramtable.h.

References ngram::freq, freq(), ngram::link, ngram::pinfo, and ngram::size.

Here is the call graph for this function:

int ngramtable::word ( node  nd  )  [inline]

Definition at line 464 of file ngramtable.h.

References tabletype::CODESIZE, getmem(), and tabletype::WORD_OFFS.

Here is the call graph for this function:

int ngramtable::word ( node  nd,
int  value 
) [inline]

Definition at line 458 of file ngramtable.h.

References tabletype::CODESIZE, putmem(), and tabletype::WORD_OFFS.

Referenced by grow(), ngramtable(), ngtbcmp(), scan(), and search().

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 320 of file ngramtable.h.

Referenced by interplm::gencorrcounts(), interplm::gensuccstat(), and ngramtable().

Definition at line 327 of file ngramtable.h.

Referenced by generate(), loadtxt(), and ngramtable().


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

Generated on Fri Apr 15 13:04:15 2011 for Moses by  doxygen 1.5.9