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, dictionary *extdict, 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)
virtual ~ngramtable ()
void freetree ()
void freetree (node nd)
void resetngramtable ()
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, dictionary *extdict=NULL)
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)
virtual 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)
bool check_dictsize_bound ()
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 codecmp (char *a, char *b)
int codediff (node a, node b)
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 301 of file ngramtable.h.


Constructor & Destructor Documentation

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

ngramtable::~ngramtable (  )  [virtual]

Definition at line 1356 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 684 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 712 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 627 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 614 of file ngramtable.h.

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

Referenced by mdiadaptlm::bodiscount(), mdiadaptlm::compute_backoff_per_level(), 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 379 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:

bool ngramtable::check_dictsize_bound (  ) 

Definition at line 1445 of file ngramtable.cpp.

References tabletype::code_range, tabletype::CODESIZE, dict, and dictionary::size().

Referenced by generate(), generate_dstco(), generate_hmask(), and main().

Here is the call graph for this function:

Here is the caller graph for this function:

int ngramtable::codecmp ( char *  a,
char *  b 
) [inline]

Definition at line 516 of file ngramtable.h.

References tabletype::CODESIZE.

Referenced by mybsearch().

Here is the caller graph for this function:

int ngramtable::codediff ( node  a,
node  b 
) [inline]

Definition at line 525 of file ngramtable.h.

References word().

Referenced by mybsearch().

Here is the call graph for this function:

Here is the caller graph for this function:

int ngramtable::comptbsize ( int  n  ) 

Definition at line 900 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 383 of file ngramtable.h.

Referenced by symshiftbeta::discount(), mdiadaptlm::saveBIN_per_level(), and mdiadaptlm::saveBIN_per_word().

Here is the caller graph for this function:

void ngramtable::freetree ( node  nd  ) 

Definition at line 1343 of file ngramtable.cpp.

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

Here is the call graph for this function:

void ngramtable::freetree (  )  [inline]

Definition at line 349 of file ngramtable.h.

Referenced by freetree(), resetngramtable(), and ~ngramtable().

Here is the caller graph for this function:

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

Definition at line 558 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 542 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,
dictionary extdict = NULL 
)

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

Definition at line 590 of file ngramtable.cpp.

References check_dictsize_bound(), mfstream::close(), cmpint(), dict, ngram::freq, dictionary::incflag(), dictionary::incfreq(), MAX_NGRAM, put(), 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 525 of file ngramtable.cpp.

References check_dictsize_bound(), mfstream::close(), dict, dictionary::incflag(), dictionary::incfreq(), MAX_NGRAM, put(), 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 
) [virtual]

Reimplemented in mixture.

Definition at line 1202 of file ngramtable.cpp.

References FIND, freq(), ngram::freq, tabletype::I_FREQ_NUM, ngram::info, ngram::lev, ngram::link, LNODE, msucc(), mtable(), mtablesz(), mtflags(), ngram::pinfo, search(), ngram::size, ngram::succ, and ngram::wordp().

Here is the call graph for this function:

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

Definition at line 436 of file ngramtable.h.

Referenced by normcache::get(), main(), prob(), 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 594 of file ngramtable.h.

References FREQ1, FREQ2, FREQ3, FREQ4, getmem(), tabletype::I_FREQ_OFFS, index, 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 470 of file ngramtable.h.

References NULL.

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

Definition at line 455 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 924 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 419 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 433 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 206 of file ngramtable.cpp.

References dictionary::decode(), dict, dictionary::encode(), filterdict, ngram::freq, dictionary::incflag(), dictionary::incfreq(), 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]

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

Definition at line 661 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 656 of file ngramtable.h.

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

Referenced by freetree(), get(), grow(), loadbin(), ngramtable(), put(), resetngramtable(), 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 675 of file ngramtable.h.

References tabletype::MTAB_OFFS, and PTRSIZE.

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

Definition at line 667 of file ngramtable.h.

References tabletype::MTAB_OFFS, and PTRSIZE.

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

Here is the caller graph for this function:

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

Definition at line 682 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 512 of file ngramtable.h.

References tabletype::FLAGS_OFFS.

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

Definition at line 508 of file ngramtable.h.

References tabletype::FLAGS_OFFS.

Referenced by freetree(), get(), grow(), loadbin(), mtablesz(), ngramtable(), put(), resetngramtable(), 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 745 of file ngramtable.cpp.

References codecmp(), codediff(), and NULL.

Referenced by search().

Here is the call graph for this function:

Here is the caller graph for this function:

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

Reimplemented in mdiadaptlm.

Definition at line 622 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 483 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 488 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 342 of file ngramtable.h.

References NULL, and str.

Referenced by main().

Here is the caller graph for this function:

double ngramtable::prob ( ngram  ng  ) 

Definition at line 1399 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 1076 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  ) 

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

Definition at line 463 of file ngramtable.h.

References NULL.

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

Definition at line 448 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::resetngramtable (  )  [inline]

Definition at line 354 of file ngramtable.h.

References freetree(), FREQ4, INODE, tabletype::inodesize(), LNODE, msucc(), mtable(), mtflags(), NULL, and word().

Referenced by mixture::get().

Here is the call graph for this function:

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 308 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 327 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 169 of file ngramtable.cpp.

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

Referenced by main(), and plsa::saveFeat().

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 810 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 577 of file ngramtable.h.

References FREQ1, FREQ2, FREQ3, FREQ4, tabletype::I_FREQ_OFFS, index, 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 731 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 1367 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 650 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 645 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 639 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 634 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 417 of file ngramtable.h.

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

Referenced by mdiadaptlm::compute_backoff_per_level(), 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 478 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 375 of file ngramtable.h.

References freq(), and INODE.

Referenced by symshiftbeta::discount(), mshiftbeta::discount(), prob(), 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 530 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 502 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 497 of file ngramtable.h.

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

Referenced by codediff(), grow(), mixture::mixture(), ngramtable(), ngtbcmp(), resetngramtable(), 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 326 of file ngramtable.h.

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

Definition at line 333 of file ngramtable.h.

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


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

Generated on Thu Jul 6 00:31:55 2017 for Moses by  doxygen 1.5.9