\doxysection{ngram\+\_\+model\+\_\+s Struct Reference}
\label{structngram__model__s}\index{ngram\_model\_s@{ngram\_model\_s}}


Common implementation of ngram\+\_\+model\+\_\+t.  




{\ttfamily \#include $<$ngram\+\_\+model\+\_\+internal.\+h$>$}

\doxysubsubsection*{Data Fields}
\begin{DoxyCompactItemize}
\item 
int \textbf{ refcount}
\begin{DoxyCompactList}\small\item\em Reference count. \end{DoxyCompactList}\item 
int32 $\ast$ \textbf{ n\+\_\+counts}
\begin{DoxyCompactList}\small\item\em Counts for 1, 2, 3, ... grams. \end{DoxyCompactList}\item 
int32 \textbf{ n\+\_\+1g\+\_\+alloc}
\begin{DoxyCompactList}\small\item\em Number of allocated word strings (for new word addition) \end{DoxyCompactList}\item 
int32 \textbf{ n\+\_\+words}
\begin{DoxyCompactList}\small\item\em Number of actual word strings (NOT the same as the number of unigrams, due to class words). \end{DoxyCompactList}\item 
uint8 \textbf{ n}
\begin{DoxyCompactList}\small\item\em This is an n-\/gram model (1, 2, 3, ...). \end{DoxyCompactList}\item 
uint8 \textbf{ n\+\_\+classes}
\begin{DoxyCompactList}\small\item\em Number of classes (maximum 128) \end{DoxyCompactList}\item 
uint8 \textbf{ writable}
\begin{DoxyCompactList}\small\item\em Are word strings writable? \end{DoxyCompactList}\item 
uint8 \textbf{ flags}
\begin{DoxyCompactList}\small\item\em Any other flags we might care about (FIXME\+: Merge this and writable) \end{DoxyCompactList}\item 
\textbf{ logmath\+\_\+t} $\ast$ \textbf{ lmath}
\begin{DoxyCompactList}\small\item\em Log-\/math object. \end{DoxyCompactList}\item 
float32 \textbf{ lw}
\begin{DoxyCompactList}\small\item\em Language model scaling factor. \end{DoxyCompactList}\item 
int32 \textbf{ log\+\_\+wip}
\begin{DoxyCompactList}\small\item\em Log of word insertion penalty. \end{DoxyCompactList}\item 
int32 \textbf{ log\+\_\+uw}
\begin{DoxyCompactList}\small\item\em Log of unigram weight. \end{DoxyCompactList}\item 
int32 \textbf{ log\+\_\+uniform}
\begin{DoxyCompactList}\small\item\em Log of uniform (0-\/gram) probability. \end{DoxyCompactList}\item 
int32 \textbf{ log\+\_\+uniform\+\_\+weight}
\begin{DoxyCompactList}\small\item\em Log of uniform weight (i.\+e. \end{DoxyCompactList}\item 
int32 \textbf{ log\+\_\+zero}
\begin{DoxyCompactList}\small\item\em Zero probability, cached here for quick lookup. \end{DoxyCompactList}\item 
char $\ast$$\ast$ \textbf{ word\+\_\+str}
\begin{DoxyCompactList}\small\item\em Unigram names. \end{DoxyCompactList}\item 
\textbf{ hash\+\_\+table\+\_\+t} $\ast$ \textbf{ wid}
\begin{DoxyCompactList}\small\item\em Mapping of unigram names to word IDs. \end{DoxyCompactList}\item 
int32 $\ast$ \textbf{ tmp\+\_\+wids}
\begin{DoxyCompactList}\small\item\em Temporary array of word IDs for ngram\+\_\+model\+\_\+get\+\_\+ngram() \end{DoxyCompactList}\item 
struct \textbf{ ngram\+\_\+class\+\_\+s} $\ast$$\ast$ \textbf{ classes}
\begin{DoxyCompactList}\small\item\em Word class definitions. \end{DoxyCompactList}\item 
struct \textbf{ ngram\+\_\+funcs\+\_\+s} $\ast$ \textbf{ funcs}
\begin{DoxyCompactList}\small\item\em Implementation-\/specific methods. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
Common implementation of ngram\+\_\+model\+\_\+t. 

The details of bigram, trigram, and higher-\/order N-\/gram storage, if any, can vary somewhat depending on the file format in use. 

Definition at line \textbf{ 55} of file \textbf{ ngram\+\_\+model\+\_\+internal.\+h}.



\doxysubsection{Field Documentation}
\label{structngram__model__s_a39384af3e6b53591d433436db011ac8d} 
\index{ngram\_model\_s@{ngram\_model\_s}!classes@{classes}}
\index{classes@{classes}!ngram\_model\_s@{ngram\_model\_s}}
\doxysubsubsection{classes}
{\footnotesize\ttfamily struct \textbf{ ngram\+\_\+class\+\_\+s}$\ast$$\ast$ ngram\+\_\+model\+\_\+s\+::classes}



Word class definitions. 



Definition at line \textbf{ 76} of file \textbf{ ngram\+\_\+model\+\_\+internal.\+h}.



Referenced by \textbf{ ngram\+\_\+model\+\_\+add\+\_\+class()}, \textbf{ ngram\+\_\+model\+\_\+add\+\_\+class\+\_\+word()}, \textbf{ ngram\+\_\+model\+\_\+free()}, \textbf{ ngram\+\_\+ng\+\_\+prob()}, and \textbf{ ngram\+\_\+ng\+\_\+score()}.

\label{structngram__model__s_ac609a2f867496d6ca719351d566db328} 
\index{ngram\_model\_s@{ngram\_model\_s}!flags@{flags}}
\index{flags@{flags}!ngram\_model\_s@{ngram\_model\_s}}
\doxysubsubsection{flags}
{\footnotesize\ttfamily uint8 ngram\+\_\+model\+\_\+s\+::flags}



Any other flags we might care about (FIXME\+: Merge this and writable) 



Definition at line \textbf{ 64} of file \textbf{ ngram\+\_\+model\+\_\+internal.\+h}.

\label{structngram__model__s_ad3d9d8ad9773f958a89534220eda6fb9} 
\index{ngram\_model\_s@{ngram\_model\_s}!funcs@{funcs}}
\index{funcs@{funcs}!ngram\_model\_s@{ngram\_model\_s}}
\doxysubsubsection{funcs}
{\footnotesize\ttfamily struct \textbf{ ngram\+\_\+funcs\+\_\+s}$\ast$ ngram\+\_\+model\+\_\+s\+::funcs}



Implementation-\/specific methods. 



Definition at line \textbf{ 77} of file \textbf{ ngram\+\_\+model\+\_\+internal.\+h}.



Referenced by \textbf{ ngram\+\_\+iter\+\_\+free()}, \textbf{ ngram\+\_\+iter\+\_\+get()}, \textbf{ ngram\+\_\+iter\+\_\+next()}, \textbf{ ngram\+\_\+iter\+\_\+successors()}, \textbf{ ngram\+\_\+model\+\_\+add\+\_\+word()}, \textbf{ ngram\+\_\+model\+\_\+apply\+\_\+weights()}, \textbf{ ngram\+\_\+model\+\_\+flush()}, \textbf{ ngram\+\_\+model\+\_\+free()}, \textbf{ ngram\+\_\+model\+\_\+mgrams()}, \textbf{ ngram\+\_\+ng\+\_\+iter()}, \textbf{ ngram\+\_\+ng\+\_\+prob()}, and \textbf{ ngram\+\_\+ng\+\_\+score()}.

\label{structngram__model__s_a2ca373109c651ac998b33153eb38fd95} 
\index{ngram\_model\_s@{ngram\_model\_s}!lmath@{lmath}}
\index{lmath@{lmath}!ngram\_model\_s@{ngram\_model\_s}}
\doxysubsubsection{lmath}
{\footnotesize\ttfamily \textbf{ logmath\+\_\+t}$\ast$ ngram\+\_\+model\+\_\+s\+::lmath}



Log-\/math object. 



Definition at line \textbf{ 66} of file \textbf{ ngram\+\_\+model\+\_\+internal.\+h}.



Referenced by \textbf{ ngram\+\_\+model\+\_\+add\+\_\+class\+\_\+word()}, \textbf{ ngram\+\_\+model\+\_\+add\+\_\+word()}, \textbf{ ngram\+\_\+model\+\_\+set\+\_\+add()}, \textbf{ ngram\+\_\+model\+\_\+set\+\_\+init()}, \textbf{ ngram\+\_\+model\+\_\+set\+\_\+interp()}, and \textbf{ ngram\+\_\+model\+\_\+set\+\_\+remove()}.

\label{structngram__model__s_a616bf871a67f9cedce17d6b589ee33ea} 
\index{ngram\_model\_s@{ngram\_model\_s}!log\_uniform@{log\_uniform}}
\index{log\_uniform@{log\_uniform}!ngram\_model\_s@{ngram\_model\_s}}
\doxysubsubsection{log\_uniform}
{\footnotesize\ttfamily int32 ngram\+\_\+model\+\_\+s\+::log\+\_\+uniform}



Log of uniform (0-\/gram) probability. 



Definition at line \textbf{ 70} of file \textbf{ ngram\+\_\+model\+\_\+internal.\+h}.

\label{structngram__model__s_aa38c5fdecaefd9a2f43b69f26ae492c1} 
\index{ngram\_model\_s@{ngram\_model\_s}!log\_uniform\_weight@{log\_uniform\_weight}}
\index{log\_uniform\_weight@{log\_uniform\_weight}!ngram\_model\_s@{ngram\_model\_s}}
\doxysubsubsection{log\_uniform\_weight}
{\footnotesize\ttfamily int32 ngram\+\_\+model\+\_\+s\+::log\+\_\+uniform\+\_\+weight}



Log of uniform weight (i.\+e. 

1 -\/ unigram weight) 

Definition at line \textbf{ 71} of file \textbf{ ngram\+\_\+model\+\_\+internal.\+h}.

\label{structngram__model__s_a6f0ec7b8b9d13d590bbe4b59df573abc} 
\index{ngram\_model\_s@{ngram\_model\_s}!log\_uw@{log\_uw}}
\index{log\_uw@{log\_uw}!ngram\_model\_s@{ngram\_model\_s}}
\doxysubsubsection{log\_uw}
{\footnotesize\ttfamily int32 ngram\+\_\+model\+\_\+s\+::log\+\_\+uw}



Log of unigram weight. 



Definition at line \textbf{ 69} of file \textbf{ ngram\+\_\+model\+\_\+internal.\+h}.



Referenced by \textbf{ ngram\+\_\+model\+\_\+get\+\_\+weights()}.

\label{structngram__model__s_a3d6bf5632760a16e52cb881d7010d774} 
\index{ngram\_model\_s@{ngram\_model\_s}!log\_wip@{log\_wip}}
\index{log\_wip@{log\_wip}!ngram\_model\_s@{ngram\_model\_s}}
\doxysubsubsection{log\_wip}
{\footnotesize\ttfamily int32 ngram\+\_\+model\+\_\+s\+::log\+\_\+wip}



Log of word insertion penalty. 



Definition at line \textbf{ 68} of file \textbf{ ngram\+\_\+model\+\_\+internal.\+h}.



Referenced by \textbf{ ngram\+\_\+model\+\_\+get\+\_\+weights()}, and \textbf{ ngram\+\_\+score\+\_\+to\+\_\+prob()}.

\label{structngram__model__s_a65425a599c4bcc4dda809d81149b8fc0} 
\index{ngram\_model\_s@{ngram\_model\_s}!log\_zero@{log\_zero}}
\index{log\_zero@{log\_zero}!ngram\_model\_s@{ngram\_model\_s}}
\doxysubsubsection{log\_zero}
{\footnotesize\ttfamily int32 ngram\+\_\+model\+\_\+s\+::log\+\_\+zero}



Zero probability, cached here for quick lookup. 



Definition at line \textbf{ 72} of file \textbf{ ngram\+\_\+model\+\_\+internal.\+h}.



Referenced by \textbf{ ngram\+\_\+model\+\_\+add\+\_\+word()}, \textbf{ ngram\+\_\+model\+\_\+set\+\_\+remove()}, \textbf{ ngram\+\_\+ng\+\_\+prob()}, \textbf{ ngram\+\_\+ng\+\_\+score()}, and \textbf{ ngram\+\_\+zero()}.

\label{structngram__model__s_a76ea0c65b23de80091e7c602bdb43bde} 
\index{ngram\_model\_s@{ngram\_model\_s}!lw@{lw}}
\index{lw@{lw}!ngram\_model\_s@{ngram\_model\_s}}
\doxysubsubsection{lw}
{\footnotesize\ttfamily float32 ngram\+\_\+model\+\_\+s\+::lw}



Language model scaling factor. 



Definition at line \textbf{ 67} of file \textbf{ ngram\+\_\+model\+\_\+internal.\+h}.



Referenced by \textbf{ ngram\+\_\+model\+\_\+get\+\_\+weights()}, and \textbf{ ngram\+\_\+score\+\_\+to\+\_\+prob()}.

\label{structngram__model__s_a3c87bc1b678662a2c8930b3b8c33a80f} 
\index{ngram\_model\_s@{ngram\_model\_s}!n@{n}}
\index{n@{n}!ngram\_model\_s@{ngram\_model\_s}}
\doxysubsubsection{n}
{\footnotesize\ttfamily uint8 ngram\+\_\+model\+\_\+s\+::n}



This is an n-\/gram model (1, 2, 3, ...). 



Definition at line \textbf{ 61} of file \textbf{ ngram\+\_\+model\+\_\+internal.\+h}.



Referenced by \textbf{ ngram\+\_\+iter\+\_\+successors()}, \textbf{ ngram\+\_\+model\+\_\+get\+\_\+size()}, \textbf{ ngram\+\_\+model\+\_\+mgrams()}, \textbf{ ngram\+\_\+model\+\_\+set\+\_\+add()}, \textbf{ ngram\+\_\+model\+\_\+set\+\_\+init()}, \textbf{ ngram\+\_\+model\+\_\+set\+\_\+remove()}, and \textbf{ ngram\+\_\+ng\+\_\+iter()}.

\label{structngram__model__s_a3e41109b30668bdfc077614c1ef49960} 
\index{ngram\_model\_s@{ngram\_model\_s}!n\_1g\_alloc@{n\_1g\_alloc}}
\index{n\_1g\_alloc@{n\_1g\_alloc}!ngram\_model\_s@{ngram\_model\_s}}
\doxysubsubsection{n\_1g\_alloc}
{\footnotesize\ttfamily int32 ngram\+\_\+model\+\_\+s\+::n\+\_\+1g\+\_\+alloc}



Number of allocated word strings (for new word addition) 



Definition at line \textbf{ 58} of file \textbf{ ngram\+\_\+model\+\_\+internal.\+h}.



Referenced by \textbf{ ngram\+\_\+model\+\_\+set\+\_\+map\+\_\+words()}.

\label{structngram__model__s_adeb914f8e9f011a5c960f5ee9cd33919} 
\index{ngram\_model\_s@{ngram\_model\_s}!n\_classes@{n\_classes}}
\index{n\_classes@{n\_classes}!ngram\_model\_s@{ngram\_model\_s}}
\doxysubsubsection{n\_classes}
{\footnotesize\ttfamily uint8 ngram\+\_\+model\+\_\+s\+::n\+\_\+classes}



Number of classes (maximum 128) 



Definition at line \textbf{ 62} of file \textbf{ ngram\+\_\+model\+\_\+internal.\+h}.



Referenced by \textbf{ ngram\+\_\+model\+\_\+add\+\_\+class()}, \textbf{ ngram\+\_\+model\+\_\+add\+\_\+class\+\_\+word()}, and \textbf{ ngram\+\_\+model\+\_\+free()}.

\label{structngram__model__s_a9dcba9b49cc1cd189b257e5838da0eee} 
\index{ngram\_model\_s@{ngram\_model\_s}!n\_counts@{n\_counts}}
\index{n\_counts@{n\_counts}!ngram\_model\_s@{ngram\_model\_s}}
\doxysubsubsection{n\_counts}
{\footnotesize\ttfamily int32$\ast$ ngram\+\_\+model\+\_\+s\+::n\+\_\+counts}



Counts for 1, 2, 3, ... grams. 



Definition at line \textbf{ 57} of file \textbf{ ngram\+\_\+model\+\_\+internal.\+h}.



Referenced by \textbf{ ngram\+\_\+model\+\_\+free()}, and \textbf{ ngram\+\_\+model\+\_\+get\+\_\+counts()}.

\label{structngram__model__s_a74f85927ef0d5513a1e6c02d13864be3} 
\index{ngram\_model\_s@{ngram\_model\_s}!n\_words@{n\_words}}
\index{n\_words@{n\_words}!ngram\_model\_s@{ngram\_model\_s}}
\doxysubsubsection{n\_words}
{\footnotesize\ttfamily int32 ngram\+\_\+model\+\_\+s\+::n\+\_\+words}



Number of actual word strings (NOT the same as the number of unigrams, due to class words). 



Definition at line \textbf{ 59} of file \textbf{ ngram\+\_\+model\+\_\+internal.\+h}.



Referenced by \textbf{ ngram\+\_\+model\+\_\+casefold()}, \textbf{ ngram\+\_\+model\+\_\+free()}, \textbf{ ngram\+\_\+model\+\_\+set\+\_\+add()}, \textbf{ ngram\+\_\+model\+\_\+set\+\_\+current\+\_\+wid()}, \textbf{ ngram\+\_\+model\+\_\+set\+\_\+known\+\_\+wid()}, \textbf{ ngram\+\_\+model\+\_\+set\+\_\+map\+\_\+words()}, \textbf{ ngram\+\_\+model\+\_\+set\+\_\+remove()}, and \textbf{ ngram\+\_\+word()}.

\label{structngram__model__s_a3b14986e4dc40ccec1f7e206b7f41d06} 
\index{ngram\_model\_s@{ngram\_model\_s}!refcount@{refcount}}
\index{refcount@{refcount}!ngram\_model\_s@{ngram\_model\_s}}
\doxysubsubsection{refcount}
{\footnotesize\ttfamily int ngram\+\_\+model\+\_\+s\+::refcount}



Reference count. 



Definition at line \textbf{ 56} of file \textbf{ ngram\+\_\+model\+\_\+internal.\+h}.



Referenced by \textbf{ ngram\+\_\+model\+\_\+free()}, and \textbf{ ngram\+\_\+model\+\_\+retain()}.

\label{structngram__model__s_a4f910ab2c18b0e68dce92816a27fb139} 
\index{ngram\_model\_s@{ngram\_model\_s}!tmp\_wids@{tmp\_wids}}
\index{tmp\_wids@{tmp\_wids}!ngram\_model\_s@{ngram\_model\_s}}
\doxysubsubsection{tmp\_wids}
{\footnotesize\ttfamily int32$\ast$ ngram\+\_\+model\+\_\+s\+::tmp\+\_\+wids}



Temporary array of word IDs for ngram\+\_\+model\+\_\+get\+\_\+ngram() 



Definition at line \textbf{ 75} of file \textbf{ ngram\+\_\+model\+\_\+internal.\+h}.

\label{structngram__model__s_a75567419a8002ef6e916c81f5d9ee9ed} 
\index{ngram\_model\_s@{ngram\_model\_s}!wid@{wid}}
\index{wid@{wid}!ngram\_model\_s@{ngram\_model\_s}}
\doxysubsubsection{wid}
{\footnotesize\ttfamily \textbf{ hash\+\_\+table\+\_\+t}$\ast$ ngram\+\_\+model\+\_\+s\+::wid}



Mapping of unigram names to word IDs. 



Definition at line \textbf{ 74} of file \textbf{ ngram\+\_\+model\+\_\+internal.\+h}.



Referenced by \textbf{ ngram\+\_\+model\+\_\+casefold()}, \textbf{ ngram\+\_\+model\+\_\+free()}, \textbf{ ngram\+\_\+model\+\_\+set\+\_\+map\+\_\+words()}, \textbf{ ngram\+\_\+unknown\+\_\+wid()}, and \textbf{ ngram\+\_\+wid()}.

\label{structngram__model__s_ae625e779e340845f03fb3da164e93039} 
\index{ngram\_model\_s@{ngram\_model\_s}!word\_str@{word\_str}}
\index{word\_str@{word\_str}!ngram\_model\_s@{ngram\_model\_s}}
\doxysubsubsection{word\_str}
{\footnotesize\ttfamily char$\ast$$\ast$ ngram\+\_\+model\+\_\+s\+::word\+\_\+str}



Unigram names. 



Definition at line \textbf{ 73} of file \textbf{ ngram\+\_\+model\+\_\+internal.\+h}.



Referenced by \textbf{ ngram\+\_\+model\+\_\+casefold()}, \textbf{ ngram\+\_\+model\+\_\+free()}, \textbf{ ngram\+\_\+model\+\_\+set\+\_\+add()}, \textbf{ ngram\+\_\+model\+\_\+set\+\_\+map\+\_\+words()}, and \textbf{ ngram\+\_\+word()}.

\label{structngram__model__s_a78a3253febced2cae4732044da466ee6} 
\index{ngram\_model\_s@{ngram\_model\_s}!writable@{writable}}
\index{writable@{writable}!ngram\_model\_s@{ngram\_model\_s}}
\doxysubsubsection{writable}
{\footnotesize\ttfamily uint8 ngram\+\_\+model\+\_\+s\+::writable}



Are word strings writable? 



Definition at line \textbf{ 63} of file \textbf{ ngram\+\_\+model\+\_\+internal.\+h}.



Referenced by \textbf{ ngram\+\_\+model\+\_\+add\+\_\+word()}, \textbf{ ngram\+\_\+model\+\_\+casefold()}, \textbf{ ngram\+\_\+model\+\_\+free()}, and \textbf{ ngram\+\_\+model\+\_\+set\+\_\+map\+\_\+words()}.



The documentation for this struct was generated from the following file\+:\begin{DoxyCompactItemize}
\item 
src/libsphinxbase/lm/ngram\+\_\+model\+\_\+internal.\+h\end{DoxyCompactItemize}
