\doxysection{src/libsphinxbase/lm/ngram\+\_\+model\+\_\+set.c File Reference}
\label{ngram__model__set_8c}\index{src/libsphinxbase/lm/ngram\_model\_set.c@{src/libsphinxbase/lm/ngram\_model\_set.c}}


Set of language models.  


{\ttfamily \#include $<$string.\+h$>$}\newline
{\ttfamily \#include $<$stdlib.\+h$>$}\newline
{\ttfamily \#include "{}sphinxbase/err.\+h"{}}\newline
{\ttfamily \#include "{}sphinxbase/ckd\+\_\+alloc.\+h"{}}\newline
{\ttfamily \#include "{}sphinxbase/strfuncs.\+h"{}}\newline
{\ttfamily \#include "{}sphinxbase/filename.\+h"{}}\newline
{\ttfamily \#include "{}ngram\+\_\+model\+\_\+set.\+h"{}}\newline
\doxysubsubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
\textbf{ ngram\+\_\+model\+\_\+t} $\ast$ \textbf{ ngram\+\_\+model\+\_\+set\+\_\+init} (\textbf{ cmd\+\_\+ln\+\_\+t} $\ast$config, \textbf{ ngram\+\_\+model\+\_\+t} $\ast$$\ast$models, char $\ast$$\ast$names, const float32 $\ast$weights, int32 n\+\_\+models)
\begin{DoxyCompactList}\small\item\em Create a set of language models sharing a common space of word IDs. \end{DoxyCompactList}\item 
\textbf{ ngram\+\_\+model\+\_\+t} $\ast$ \textbf{ ngram\+\_\+model\+\_\+set\+\_\+read} (\textbf{ cmd\+\_\+ln\+\_\+t} $\ast$config, const char $\ast$lmctlfile, \textbf{ logmath\+\_\+t} $\ast$lmath)
\begin{DoxyCompactList}\small\item\em Read a set of language models from a control file. \end{DoxyCompactList}\item 
int32 \textbf{ ngram\+\_\+model\+\_\+set\+\_\+count} (\textbf{ ngram\+\_\+model\+\_\+t} $\ast$base)
\begin{DoxyCompactList}\small\item\em Returns the number of language models in a set. \end{DoxyCompactList}\item 
\textbf{ ngram\+\_\+model\+\_\+set\+\_\+iter\+\_\+t} $\ast$ \textbf{ ngram\+\_\+model\+\_\+set\+\_\+iter} (\textbf{ ngram\+\_\+model\+\_\+t} $\ast$base)
\begin{DoxyCompactList}\small\item\em Begin iterating over language models in a set. \end{DoxyCompactList}\item 
\textbf{ ngram\+\_\+model\+\_\+set\+\_\+iter\+\_\+t} $\ast$ \textbf{ ngram\+\_\+model\+\_\+set\+\_\+iter\+\_\+next} (\textbf{ ngram\+\_\+model\+\_\+set\+\_\+iter\+\_\+t} $\ast$itor)
\begin{DoxyCompactList}\small\item\em Move to the next language model in a set. \end{DoxyCompactList}\item 
void \textbf{ ngram\+\_\+model\+\_\+set\+\_\+iter\+\_\+free} (\textbf{ ngram\+\_\+model\+\_\+set\+\_\+iter\+\_\+t} $\ast$itor)
\begin{DoxyCompactList}\small\item\em Finish iteration over a langauge model set. \end{DoxyCompactList}\item 
\textbf{ ngram\+\_\+model\+\_\+t} $\ast$ \textbf{ ngram\+\_\+model\+\_\+set\+\_\+iter\+\_\+model} (\textbf{ ngram\+\_\+model\+\_\+set\+\_\+iter\+\_\+t} $\ast$itor, char const $\ast$$\ast$lmname)
\begin{DoxyCompactList}\small\item\em Get language model and associated name from an iterator. \end{DoxyCompactList}\item 
\textbf{ ngram\+\_\+model\+\_\+t} $\ast$ \textbf{ ngram\+\_\+model\+\_\+set\+\_\+lookup} (\textbf{ ngram\+\_\+model\+\_\+t} $\ast$base, const char $\ast$name)
\begin{DoxyCompactList}\small\item\em Look up a language model by name from a set. \end{DoxyCompactList}\item 
\textbf{ ngram\+\_\+model\+\_\+t} $\ast$ \textbf{ ngram\+\_\+model\+\_\+set\+\_\+select} (\textbf{ ngram\+\_\+model\+\_\+t} $\ast$base, const char $\ast$name)
\begin{DoxyCompactList}\small\item\em Select a single language model from a set for scoring. \end{DoxyCompactList}\item 
const char $\ast$ \textbf{ ngram\+\_\+model\+\_\+set\+\_\+current} (\textbf{ ngram\+\_\+model\+\_\+t} $\ast$base)
\begin{DoxyCompactList}\small\item\em Get the current language model name, if any. \end{DoxyCompactList}\item 
int32 \textbf{ ngram\+\_\+model\+\_\+set\+\_\+current\+\_\+wid} (\textbf{ ngram\+\_\+model\+\_\+t} $\ast$base, int32 set\+\_\+wid)
\begin{DoxyCompactList}\small\item\em Query the word-\/\+ID mapping for the current language model. \end{DoxyCompactList}\item 
int32 \textbf{ ngram\+\_\+model\+\_\+set\+\_\+known\+\_\+wid} (\textbf{ ngram\+\_\+model\+\_\+t} $\ast$base, int32 set\+\_\+wid)
\begin{DoxyCompactList}\small\item\em Test whether a word ID corresponds to a known word in the current state of the language model set. \end{DoxyCompactList}\item 
\textbf{ ngram\+\_\+model\+\_\+t} $\ast$ \textbf{ ngram\+\_\+model\+\_\+set\+\_\+interp} (\textbf{ ngram\+\_\+model\+\_\+t} $\ast$base, const char $\ast$$\ast$names, const float32 $\ast$weights)
\begin{DoxyCompactList}\small\item\em Set interpolation weights for a set and enables interpolation. \end{DoxyCompactList}\item 
\textbf{ ngram\+\_\+model\+\_\+t} $\ast$ \textbf{ ngram\+\_\+model\+\_\+set\+\_\+add} (\textbf{ ngram\+\_\+model\+\_\+t} $\ast$base, \textbf{ ngram\+\_\+model\+\_\+t} $\ast$model, const char $\ast$name, float32 weight, int reuse\+\_\+widmap)
\begin{DoxyCompactList}\small\item\em Add a language model to a set. \end{DoxyCompactList}\item 
\textbf{ ngram\+\_\+model\+\_\+t} $\ast$ \textbf{ ngram\+\_\+model\+\_\+set\+\_\+remove} (\textbf{ ngram\+\_\+model\+\_\+t} $\ast$base, const char $\ast$name, int reuse\+\_\+widmap)
\begin{DoxyCompactList}\small\item\em Remove a language model from a set. \end{DoxyCompactList}\item 
void \textbf{ ngram\+\_\+model\+\_\+set\+\_\+map\+\_\+words} (\textbf{ ngram\+\_\+model\+\_\+t} $\ast$base, const char $\ast$$\ast$words, int32 n\+\_\+words)
\begin{DoxyCompactList}\small\item\em Set the word-\/to-\/\+ID mapping for this model set. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
Set of language models. 

\begin{DoxyAuthor}{Author}
David Huggins-\/\+Daines {\texttt{ dhuggins@cs.\+cmu.\+edu}} 
\end{DoxyAuthor}


Definition in file \textbf{ ngram\+\_\+model\+\_\+set.\+c}.



\doxysubsection{Function Documentation}
\label{ngram__model__set_8c_a5ccb37b09162e8d0fa242758c2c1f808} 
\index{ngram\_model\_set.c@{ngram\_model\_set.c}!ngram\_model\_set\_add@{ngram\_model\_set\_add}}
\index{ngram\_model\_set\_add@{ngram\_model\_set\_add}!ngram\_model\_set.c@{ngram\_model\_set.c}}
\doxysubsubsection{ngram\_model\_set\_add()}
{\footnotesize\ttfamily \textbf{ ngram\+\_\+model\+\_\+t} $\ast$ ngram\+\_\+model\+\_\+set\+\_\+add (\begin{DoxyParamCaption}\item[{\textbf{ ngram\+\_\+model\+\_\+t} $\ast$}]{set,  }\item[{\textbf{ ngram\+\_\+model\+\_\+t} $\ast$}]{model,  }\item[{const char $\ast$}]{name,  }\item[{float32}]{weight,  }\item[{int}]{reuse\+\_\+widmap }\end{DoxyParamCaption})}



Add a language model to a set. 


\begin{DoxyParams}{Parameters}
{\em set} & The language model set to add to. \\
\hline
{\em model} & The language model to add. \\
\hline
{\em name} & The name to associate with this model. \\
\hline
{\em weight} & Interpolation weight for this model, relative to the uniform distribution. 1.\+0 is a safe value. \\
\hline
{\em reuse\+\_\+widmap} & Reuse the existing word-\/\+ID mapping in {\ttfamily set}. Any new words present in {\ttfamily model} will not be added to the word-\/\+ID mapping in this case. \\
\hline
\end{DoxyParams}


Definition at line \textbf{ 520} of file \textbf{ ngram\+\_\+model\+\_\+set.\+c}.



References \textbf{ ckd\+\_\+calloc\+\_\+2d}, \textbf{ ckd\+\_\+free\+\_\+2d()}, \textbf{ ckd\+\_\+realloc}, \textbf{ ckd\+\_\+salloc}, \textbf{ ngram\+\_\+model\+\_\+s\+::lmath}, \textbf{ ngram\+\_\+model\+\_\+set\+\_\+s\+::lms}, \textbf{ logmath\+\_\+log()}, \textbf{ ngram\+\_\+model\+\_\+set\+\_\+s\+::lweights}, \textbf{ ngram\+\_\+model\+\_\+set\+\_\+s\+::maphist}, \textbf{ ngram\+\_\+model\+\_\+s\+::n}, \textbf{ ngram\+\_\+model\+\_\+set\+\_\+s\+::n\+\_\+models}, \textbf{ ngram\+\_\+model\+\_\+s\+::n\+\_\+words}, \textbf{ ngram\+\_\+model\+\_\+set\+\_\+s\+::names}, \textbf{ ngram\+\_\+wid()}, \textbf{ ngram\+\_\+model\+\_\+set\+\_\+s\+::widmap}, and \textbf{ ngram\+\_\+model\+\_\+s\+::word\+\_\+str}.

\label{ngram__model__set_8c_afa38d4e0f6cd64cc2875000fcef487f0} 
\index{ngram\_model\_set.c@{ngram\_model\_set.c}!ngram\_model\_set\_count@{ngram\_model\_set\_count}}
\index{ngram\_model\_set\_count@{ngram\_model\_set\_count}!ngram\_model\_set.c@{ngram\_model\_set.c}}
\doxysubsubsection{ngram\_model\_set\_count()}
{\footnotesize\ttfamily int32 ngram\+\_\+model\+\_\+set\+\_\+count (\begin{DoxyParamCaption}\item[{\textbf{ ngram\+\_\+model\+\_\+t} $\ast$}]{base }\end{DoxyParamCaption})}



Returns the number of language models in a set. 



Definition at line \textbf{ 361} of file \textbf{ ngram\+\_\+model\+\_\+set.\+c}.



References \textbf{ ngram\+\_\+model\+\_\+set\+\_\+s\+::n\+\_\+models}.

\label{ngram__model__set_8c_a1992e2f60a4f3c91e36c3032e0ea7572} 
\index{ngram\_model\_set.c@{ngram\_model\_set.c}!ngram\_model\_set\_current@{ngram\_model\_set\_current}}
\index{ngram\_model\_set\_current@{ngram\_model\_set\_current}!ngram\_model\_set.c@{ngram\_model\_set.c}}
\doxysubsubsection{ngram\_model\_set\_current()}
{\footnotesize\ttfamily const char $\ast$ ngram\+\_\+model\+\_\+set\+\_\+current (\begin{DoxyParamCaption}\item[{\textbf{ ngram\+\_\+model\+\_\+t} $\ast$}]{base }\end{DoxyParamCaption})}



Get the current language model name, if any. 



Definition at line \textbf{ 445} of file \textbf{ ngram\+\_\+model\+\_\+set.\+c}.



References \textbf{ ngram\+\_\+model\+\_\+set\+\_\+s\+::cur}, and \textbf{ ngram\+\_\+model\+\_\+set\+\_\+s\+::names}.

\label{ngram__model__set_8c_aa6239b58f333177839a15de79bae6146} 
\index{ngram\_model\_set.c@{ngram\_model\_set.c}!ngram\_model\_set\_current\_wid@{ngram\_model\_set\_current\_wid}}
\index{ngram\_model\_set\_current\_wid@{ngram\_model\_set\_current\_wid}!ngram\_model\_set.c@{ngram\_model\_set.c}}
\doxysubsubsection{ngram\_model\_set\_current\_wid()}
{\footnotesize\ttfamily int32 ngram\+\_\+model\+\_\+set\+\_\+current\+\_\+wid (\begin{DoxyParamCaption}\item[{\textbf{ ngram\+\_\+model\+\_\+t} $\ast$}]{set,  }\item[{int32}]{set\+\_\+wid }\end{DoxyParamCaption})}



Query the word-\/\+ID mapping for the current language model. 

\begin{DoxyReturn}{Returns}
the local word ID in the current language model, or NGRAM\+\_\+\+INVALID\+\_\+\+WID if {\ttfamily set\+\_\+wid} is invalid or interpolation is enabled. 
\end{DoxyReturn}


Definition at line \textbf{ 456} of file \textbf{ ngram\+\_\+model\+\_\+set.\+c}.



References \textbf{ ngram\+\_\+model\+\_\+set\+\_\+s\+::cur}, \textbf{ ngram\+\_\+model\+\_\+s\+::n\+\_\+words}, \textbf{ NGRAM\+\_\+\+INVALID\+\_\+\+WID}, and \textbf{ ngram\+\_\+model\+\_\+set\+\_\+s\+::widmap}.

\label{ngram__model__set_8c_abf0eb54eada6979cc18de199f6c73965} 
\index{ngram\_model\_set.c@{ngram\_model\_set.c}!ngram\_model\_set\_init@{ngram\_model\_set\_init}}
\index{ngram\_model\_set\_init@{ngram\_model\_set\_init}!ngram\_model\_set.c@{ngram\_model\_set.c}}
\doxysubsubsection{ngram\_model\_set\_init()}
{\footnotesize\ttfamily \textbf{ ngram\+\_\+model\+\_\+t} $\ast$ ngram\+\_\+model\+\_\+set\+\_\+init (\begin{DoxyParamCaption}\item[{\textbf{ cmd\+\_\+ln\+\_\+t} $\ast$}]{config,  }\item[{\textbf{ ngram\+\_\+model\+\_\+t} $\ast$$\ast$}]{models,  }\item[{char $\ast$$\ast$}]{names,  }\item[{const float32 $\ast$}]{weights,  }\item[{int32}]{n\+\_\+models }\end{DoxyParamCaption})}



Create a set of language models sharing a common space of word IDs. 

This function creates a meta-\/language model which groups together a set of language models, synchronizing word IDs between them. To use this language model, you can either select a submodel to use exclusively using \doxyref{ngram\+\_\+model\+\_\+set\+\_\+select()}{p.}{ngram__model_8h_aceac963816f86190d835838f27f94569}, or interpolate between scores from all models. To do the latter, you can either pass a non-\/\+NULL value of the {\ttfamily weights} parameter, or re-\/activate interpolation later on by calling \doxyref{ngram\+\_\+model\+\_\+set\+\_\+interp()}{p.}{ngram__model_8h_acdf2c7991417a4bf175fe37404a6764c}.

In order to make this efficient, there are some restrictions on the models that can be grouped together. The most important (and currently the only) one is that they {\bfseries{must}} all share the same log-\/math parameters.


\begin{DoxyParams}{Parameters}
{\em config} & Any configuration parameters to be shared between models. \\
\hline
{\em models} & Array of pointers to previously created language models. \\
\hline
{\em names} & Array of strings to use as unique identifiers for LMs. \\
\hline
{\em weights} & Array of weights to use in interpolating LMs, or NULL for no interpolation. \\
\hline
{\em n\+\_\+models} & Number of elements in the arrays passed to this function. \\
\hline
\end{DoxyParams}


Definition at line \textbf{ 121} of file \textbf{ ngram\+\_\+model\+\_\+set.\+c}.



References \textbf{ ngram\+\_\+model\+\_\+set\+\_\+s\+::base}, \textbf{ ckd\+\_\+calloc}, \textbf{ ckd\+\_\+salloc}, \textbf{ ngram\+\_\+model\+\_\+set\+\_\+s\+::cur}, \textbf{ E\+\_\+\+ERROR}, \textbf{ ngram\+\_\+model\+\_\+s\+::lmath}, \textbf{ ngram\+\_\+model\+\_\+set\+\_\+s\+::lms}, \textbf{ logmath\+\_\+get\+\_\+base()}, \textbf{ logmath\+\_\+get\+\_\+shift()}, \textbf{ logmath\+\_\+log()}, \textbf{ ngram\+\_\+model\+\_\+set\+\_\+s\+::lweights}, \textbf{ ngram\+\_\+model\+\_\+set\+\_\+s\+::maphist}, \textbf{ ngram\+\_\+model\+\_\+s\+::n}, \textbf{ ngram\+\_\+model\+\_\+set\+\_\+s\+::n\+\_\+models}, and \textbf{ ngram\+\_\+model\+\_\+set\+\_\+s\+::names}.



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

\label{ngram__model__set_8c_aa535a4abca22fb097908266504d52698} 
\index{ngram\_model\_set.c@{ngram\_model\_set.c}!ngram\_model\_set\_interp@{ngram\_model\_set\_interp}}
\index{ngram\_model\_set\_interp@{ngram\_model\_set\_interp}!ngram\_model\_set.c@{ngram\_model\_set.c}}
\doxysubsubsection{ngram\_model\_set\_interp()}
{\footnotesize\ttfamily \textbf{ ngram\+\_\+model\+\_\+t} $\ast$ ngram\+\_\+model\+\_\+set\+\_\+interp (\begin{DoxyParamCaption}\item[{\textbf{ ngram\+\_\+model\+\_\+t} $\ast$}]{set,  }\item[{const char $\ast$$\ast$}]{names,  }\item[{const float32 $\ast$}]{weights }\end{DoxyParamCaption})}



Set interpolation weights for a set and enables interpolation. 

If {\ttfamily weights} is NULL, any previously initialized set of weights will be used. If no weights were specified to \doxyref{ngram\+\_\+model\+\_\+set\+\_\+init()}{p.}{ngram__model_8h_a591eee716c0f8eb3cdea62276a616f64}, then a uniform distribution will be used. 

Definition at line \textbf{ 489} of file \textbf{ ngram\+\_\+model\+\_\+set.\+c}.



References \textbf{ ngram\+\_\+model\+\_\+set\+\_\+s\+::cur}, \textbf{ E\+\_\+\+ERROR}, \textbf{ ngram\+\_\+model\+\_\+s\+::lmath}, \textbf{ logmath\+\_\+log()}, \textbf{ ngram\+\_\+model\+\_\+set\+\_\+s\+::lweights}, \textbf{ ngram\+\_\+model\+\_\+set\+\_\+s\+::n\+\_\+models}, and \textbf{ ngram\+\_\+model\+\_\+set\+\_\+s\+::names}.

\label{ngram__model__set_8c_a402bf8c7d09af62d99b06e518a9935a5} 
\index{ngram\_model\_set.c@{ngram\_model\_set.c}!ngram\_model\_set\_iter@{ngram\_model\_set\_iter}}
\index{ngram\_model\_set\_iter@{ngram\_model\_set\_iter}!ngram\_model\_set.c@{ngram\_model\_set.c}}
\doxysubsubsection{ngram\_model\_set\_iter()}
{\footnotesize\ttfamily \textbf{ ngram\+\_\+model\+\_\+set\+\_\+iter\+\_\+t} $\ast$ ngram\+\_\+model\+\_\+set\+\_\+iter (\begin{DoxyParamCaption}\item[{\textbf{ ngram\+\_\+model\+\_\+t} $\ast$}]{set }\end{DoxyParamCaption})}



Begin iterating over language models in a set. 

\begin{DoxyReturn}{Returns}
iterator pointing to the first language model, or NULL if no models remain. 
\end{DoxyReturn}


Definition at line \textbf{ 368} of file \textbf{ ngram\+\_\+model\+\_\+set.\+c}.



References \textbf{ ckd\+\_\+calloc}, and \textbf{ ngram\+\_\+model\+\_\+set\+\_\+s\+::n\+\_\+models}.

\label{ngram__model__set_8c_a532787b5b709d0c5f0ad57e3df0d1d73} 
\index{ngram\_model\_set.c@{ngram\_model\_set.c}!ngram\_model\_set\_iter\_free@{ngram\_model\_set\_iter\_free}}
\index{ngram\_model\_set\_iter\_free@{ngram\_model\_set\_iter\_free}!ngram\_model\_set.c@{ngram\_model\_set.c}}
\doxysubsubsection{ngram\_model\_set\_iter\_free()}
{\footnotesize\ttfamily void ngram\+\_\+model\+\_\+set\+\_\+iter\+\_\+free (\begin{DoxyParamCaption}\item[{\textbf{ ngram\+\_\+model\+\_\+set\+\_\+iter\+\_\+t} $\ast$}]{itor }\end{DoxyParamCaption})}



Finish iteration over a langauge model set. 



Definition at line \textbf{ 391} of file \textbf{ ngram\+\_\+model\+\_\+set.\+c}.



References \textbf{ ckd\+\_\+free()}.



Referenced by \textbf{ ngram\+\_\+model\+\_\+set\+\_\+iter\+\_\+next()}.

\label{ngram__model__set_8c_acfc2821131c3f6c4c3ee8a90e79edd85} 
\index{ngram\_model\_set.c@{ngram\_model\_set.c}!ngram\_model\_set\_iter\_model@{ngram\_model\_set\_iter\_model}}
\index{ngram\_model\_set\_iter\_model@{ngram\_model\_set\_iter\_model}!ngram\_model\_set.c@{ngram\_model\_set.c}}
\doxysubsubsection{ngram\_model\_set\_iter\_model()}
{\footnotesize\ttfamily \textbf{ ngram\+\_\+model\+\_\+t} $\ast$ ngram\+\_\+model\+\_\+set\+\_\+iter\+\_\+model (\begin{DoxyParamCaption}\item[{\textbf{ ngram\+\_\+model\+\_\+set\+\_\+iter\+\_\+t} $\ast$}]{itor,  }\item[{char const $\ast$$\ast$}]{lmname }\end{DoxyParamCaption})}



Get language model and associated name from an iterator. 


\begin{DoxyParams}{Parameters}
{\em itor} & the iterator \\
\hline
{\em lmname} & Output\+: string name associated with this language model. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Language model pointed to by this iterator. 
\end{DoxyReturn}


Definition at line \textbf{ 397} of file \textbf{ ngram\+\_\+model\+\_\+set.\+c}.



References \textbf{ ngram\+\_\+model\+\_\+set\+\_\+s\+::lms}, and \textbf{ ngram\+\_\+model\+\_\+set\+\_\+s\+::names}.

\label{ngram__model__set_8c_a4e60e6a4483e7ff59d8f52332b1a6e3e} 
\index{ngram\_model\_set.c@{ngram\_model\_set.c}!ngram\_model\_set\_iter\_next@{ngram\_model\_set\_iter\_next}}
\index{ngram\_model\_set\_iter\_next@{ngram\_model\_set\_iter\_next}!ngram\_model\_set.c@{ngram\_model\_set.c}}
\doxysubsubsection{ngram\_model\_set\_iter\_next()}
{\footnotesize\ttfamily \textbf{ ngram\+\_\+model\+\_\+set\+\_\+iter\+\_\+t} $\ast$ ngram\+\_\+model\+\_\+set\+\_\+iter\+\_\+next (\begin{DoxyParamCaption}\item[{\textbf{ ngram\+\_\+model\+\_\+set\+\_\+iter\+\_\+t} $\ast$}]{itor }\end{DoxyParamCaption})}



Move to the next language model in a set. 

\begin{DoxyReturn}{Returns}
iterator pointing to the next language model, or NULL if no models remain. 
\end{DoxyReturn}


Definition at line \textbf{ 381} of file \textbf{ ngram\+\_\+model\+\_\+set.\+c}.



References \textbf{ ngram\+\_\+model\+\_\+set\+\_\+s\+::n\+\_\+models}, and \textbf{ ngram\+\_\+model\+\_\+set\+\_\+iter\+\_\+free()}.

\label{ngram__model__set_8c_af30197146b9b2d6c143914240dee3c04} 
\index{ngram\_model\_set.c@{ngram\_model\_set.c}!ngram\_model\_set\_known\_wid@{ngram\_model\_set\_known\_wid}}
\index{ngram\_model\_set\_known\_wid@{ngram\_model\_set\_known\_wid}!ngram\_model\_set.c@{ngram\_model\_set.c}}
\doxysubsubsection{ngram\_model\_set\_known\_wid()}
{\footnotesize\ttfamily int32 ngram\+\_\+model\+\_\+set\+\_\+known\+\_\+wid (\begin{DoxyParamCaption}\item[{\textbf{ ngram\+\_\+model\+\_\+t} $\ast$}]{set,  }\item[{int32}]{set\+\_\+wid }\end{DoxyParamCaption})}



Test whether a word ID corresponds to a known word in the current state of the language model set. 

\begin{DoxyReturn}{Returns}
If there is a current language model, returns non-\/zero if {\ttfamily set\+\_\+wid} corresponds to a known word in that language model. Otherwise, returns non-\/zero if {\ttfamily set\+\_\+wid} corresponds to a known word in any language model. 
\end{DoxyReturn}


Definition at line \textbf{ 468} of file \textbf{ ngram\+\_\+model\+\_\+set.\+c}.



References \textbf{ ngram\+\_\+model\+\_\+set\+\_\+s\+::cur}, \textbf{ ngram\+\_\+model\+\_\+set\+\_\+s\+::lms}, \textbf{ ngram\+\_\+model\+\_\+set\+\_\+s\+::n\+\_\+models}, \textbf{ ngram\+\_\+model\+\_\+s\+::n\+\_\+words}, \textbf{ ngram\+\_\+unknown\+\_\+wid()}, and \textbf{ ngram\+\_\+model\+\_\+set\+\_\+s\+::widmap}.

\label{ngram__model__set_8c_ae715305c6e36abcf895c12ad61aa39ed} 
\index{ngram\_model\_set.c@{ngram\_model\_set.c}!ngram\_model\_set\_lookup@{ngram\_model\_set\_lookup}}
\index{ngram\_model\_set\_lookup@{ngram\_model\_set\_lookup}!ngram\_model\_set.c@{ngram\_model\_set.c}}
\doxysubsubsection{ngram\_model\_set\_lookup()}
{\footnotesize\ttfamily \textbf{ ngram\+\_\+model\+\_\+t} $\ast$ ngram\+\_\+model\+\_\+set\+\_\+lookup (\begin{DoxyParamCaption}\item[{\textbf{ ngram\+\_\+model\+\_\+t} $\ast$}]{set,  }\item[{const char $\ast$}]{name }\end{DoxyParamCaption})}



Look up a language model by name from a set. 

\begin{DoxyReturn}{Returns}
language model corresponding to {\ttfamily name}, or NULL if no language model by that name exists. 
\end{DoxyReturn}


Definition at line \textbf{ 405} of file \textbf{ ngram\+\_\+model\+\_\+set.\+c}.



References \textbf{ ngram\+\_\+model\+\_\+set\+\_\+s\+::cur}, \textbf{ ngram\+\_\+model\+\_\+set\+\_\+s\+::lms}, \textbf{ ngram\+\_\+model\+\_\+set\+\_\+s\+::n\+\_\+models}, and \textbf{ ngram\+\_\+model\+\_\+set\+\_\+s\+::names}.

\label{ngram__model__set_8c_af3ac3bbec3eed0b9638c4e64c8b75949} 
\index{ngram\_model\_set.c@{ngram\_model\_set.c}!ngram\_model\_set\_map\_words@{ngram\_model\_set\_map\_words}}
\index{ngram\_model\_set\_map\_words@{ngram\_model\_set\_map\_words}!ngram\_model\_set.c@{ngram\_model\_set.c}}
\doxysubsubsection{ngram\_model\_set\_map\_words()}
{\footnotesize\ttfamily void ngram\+\_\+model\+\_\+set\+\_\+map\+\_\+words (\begin{DoxyParamCaption}\item[{\textbf{ ngram\+\_\+model\+\_\+t} $\ast$}]{base,  }\item[{const char $\ast$$\ast$}]{words,  }\item[{int32}]{n\+\_\+words }\end{DoxyParamCaption})}



Set the word-\/to-\/\+ID mapping for this model set. 



Definition at line \textbf{ 637} of file \textbf{ ngram\+\_\+model\+\_\+set.\+c}.



References \textbf{ ckd\+\_\+calloc}, \textbf{ ckd\+\_\+calloc\+\_\+2d}, \textbf{ ckd\+\_\+free()}, \textbf{ ckd\+\_\+free\+\_\+2d()}, \textbf{ ckd\+\_\+salloc}, \textbf{ hash\+\_\+table\+\_\+empty()}, \textbf{ hash\+\_\+table\+\_\+enter\+\_\+int32}, \textbf{ ngram\+\_\+model\+\_\+set\+\_\+s\+::lms}, \textbf{ ngram\+\_\+model\+\_\+s\+::n\+\_\+1g\+\_\+alloc}, \textbf{ ngram\+\_\+model\+\_\+set\+\_\+s\+::n\+\_\+models}, \textbf{ ngram\+\_\+model\+\_\+s\+::n\+\_\+words}, \textbf{ ngram\+\_\+wid()}, \textbf{ ngram\+\_\+model\+\_\+s\+::wid}, \textbf{ ngram\+\_\+model\+\_\+set\+\_\+s\+::widmap}, \textbf{ ngram\+\_\+model\+\_\+s\+::word\+\_\+str}, and \textbf{ ngram\+\_\+model\+\_\+s\+::writable}.

\label{ngram__model__set_8c_a34f5244b2b89f8757ffd8c205ddd039f} 
\index{ngram\_model\_set.c@{ngram\_model\_set.c}!ngram\_model\_set\_read@{ngram\_model\_set\_read}}
\index{ngram\_model\_set\_read@{ngram\_model\_set\_read}!ngram\_model\_set.c@{ngram\_model\_set.c}}
\doxysubsubsection{ngram\_model\_set\_read()}
{\footnotesize\ttfamily \textbf{ ngram\+\_\+model\+\_\+t} $\ast$ ngram\+\_\+model\+\_\+set\+\_\+read (\begin{DoxyParamCaption}\item[{\textbf{ cmd\+\_\+ln\+\_\+t} $\ast$}]{config,  }\item[{const char $\ast$}]{lmctlfile,  }\item[{\textbf{ logmath\+\_\+t} $\ast$}]{lmath }\end{DoxyParamCaption})}



Read a set of language models from a control file. 

This file creates a language model set from a "{}control file"{} of the type used in Sphinx-\/\+II and Sphinx-\/\+III. File format (optional stuff is indicated by enclosing in [])\+:


\begin{DoxyPre}
  [\{ LMClassFileName LMClassFilename ... \}]
  TrigramLMFileName LMName [\{ LMClassName LMClassName ... \}]
  TrigramLMFileName LMName [\{ LMClassName LMClassName ... \}]
  ...
(There should be whitespace around the \{ and \} delimiters.)
\end{DoxyPre}


This is an extension of the older format that had only Trigram\+LMFilen\+Name and LMName pairs. The new format allows a set of LMClass files to be read in and referred to by the trigram LMs.

No "{}comments"{} allowed in this file.


\begin{DoxyParams}{Parameters}
{\em config} & Configuration parameters. \\
\hline
{\em lmctlfile} & Path to the language model control file. \\
\hline
{\em lmath} & Log-\/math parameters to use for probability calculations. Ownership of this object is assumed by the newly created ngram\+\_\+model\+\_\+t, and you should not attempt to free it manually. If you wish to reuse it elsewhere, you must retain it with \doxyref{logmath\+\_\+retain()}{p.}{logmath_8h_adad8494649ef2e49cde1c5ad3ccbe072}. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
newly created language model set. 
\end{DoxyReturn}


Definition at line \textbf{ 182} of file \textbf{ ngram\+\_\+model\+\_\+set.\+c}.



References \textbf{ ckd\+\_\+calloc}, \textbf{ ckd\+\_\+free()}, \textbf{ ckd\+\_\+salloc}, \textbf{ E\+\_\+\+ERROR}, \textbf{ E\+\_\+\+ERROR\+\_\+\+SYSTEM}, \textbf{ E\+\_\+\+INFO}, \textbf{ glist\+\_\+add\+\_\+ptr()}, \textbf{ glist\+\_\+count()}, \textbf{ glist\+\_\+free()}, \textbf{ glist\+\_\+reverse()}, \textbf{ gnode\+\_\+ptr}, \textbf{ hash\+\_\+table\+\_\+free()}, \textbf{ hash\+\_\+table\+\_\+lookup()}, \textbf{ hash\+\_\+table\+\_\+new()}, \textbf{ hash\+\_\+table\+\_\+tolist()}, \textbf{ NGRAM\+\_\+\+AUTO}, \textbf{ ngram\+\_\+model\+\_\+add\+\_\+class()}, \textbf{ ngram\+\_\+model\+\_\+free()}, \textbf{ ngram\+\_\+model\+\_\+read()}, \textbf{ ngram\+\_\+model\+\_\+set\+\_\+init()}, \textbf{ path\+\_\+is\+\_\+absolute()}, \textbf{ string\+\_\+join()}, and \textbf{ hash\+\_\+entry\+\_\+s\+::val}.

\label{ngram__model__set_8c_a973073bb92c77178711059394b807de6} 
\index{ngram\_model\_set.c@{ngram\_model\_set.c}!ngram\_model\_set\_remove@{ngram\_model\_set\_remove}}
\index{ngram\_model\_set\_remove@{ngram\_model\_set\_remove}!ngram\_model\_set.c@{ngram\_model\_set.c}}
\doxysubsubsection{ngram\_model\_set\_remove()}
{\footnotesize\ttfamily \textbf{ ngram\+\_\+model\+\_\+t} $\ast$ ngram\+\_\+model\+\_\+set\+\_\+remove (\begin{DoxyParamCaption}\item[{\textbf{ ngram\+\_\+model\+\_\+t} $\ast$}]{set,  }\item[{const char $\ast$}]{name,  }\item[{int}]{reuse\+\_\+widmap }\end{DoxyParamCaption})}



Remove a language model from a set. 


\begin{DoxyParams}{Parameters}
{\em set} & The language model set to remove from. \\
\hline
{\em name} & The name associated with the model to remove. \\
\hline
{\em reuse\+\_\+widmap} & Reuse the existing word-\/\+ID mapping in {\ttfamily set}. \\
\hline
\end{DoxyParams}


Definition at line \textbf{ 580} of file \textbf{ ngram\+\_\+model\+\_\+set.\+c}.



References \textbf{ ckd\+\_\+free()}, \textbf{ ngram\+\_\+model\+\_\+s\+::lmath}, \textbf{ ngram\+\_\+model\+\_\+set\+\_\+s\+::lms}, \textbf{ ngram\+\_\+model\+\_\+s\+::log\+\_\+zero}, \textbf{ logmath\+\_\+exp()}, \textbf{ logmath\+\_\+log()}, \textbf{ ngram\+\_\+model\+\_\+set\+\_\+s\+::lweights}, \textbf{ ngram\+\_\+model\+\_\+s\+::n}, \textbf{ ngram\+\_\+model\+\_\+set\+\_\+s\+::n\+\_\+models}, \textbf{ ngram\+\_\+model\+\_\+s\+::n\+\_\+words}, \textbf{ ngram\+\_\+model\+\_\+set\+\_\+s\+::names}, and \textbf{ ngram\+\_\+model\+\_\+set\+\_\+s\+::widmap}.

\label{ngram__model__set_8c_a7509613f8ac75ee28fccb4a6bb53bb03} 
\index{ngram\_model\_set.c@{ngram\_model\_set.c}!ngram\_model\_set\_select@{ngram\_model\_set\_select}}
\index{ngram\_model\_set\_select@{ngram\_model\_set\_select}!ngram\_model\_set.c@{ngram\_model\_set.c}}
\doxysubsubsection{ngram\_model\_set\_select()}
{\footnotesize\ttfamily \textbf{ ngram\+\_\+model\+\_\+t} $\ast$ ngram\+\_\+model\+\_\+set\+\_\+select (\begin{DoxyParamCaption}\item[{\textbf{ ngram\+\_\+model\+\_\+t} $\ast$}]{set,  }\item[{const char $\ast$}]{name }\end{DoxyParamCaption})}



Select a single language model from a set for scoring. 

\begin{DoxyReturn}{Returns}
the newly selected language model, or NULL if no language model by that name exists. 
\end{DoxyReturn}


Definition at line \textbf{ 428} of file \textbf{ ngram\+\_\+model\+\_\+set.\+c}.



References \textbf{ ngram\+\_\+model\+\_\+set\+\_\+s\+::cur}, \textbf{ ngram\+\_\+model\+\_\+set\+\_\+s\+::lms}, \textbf{ ngram\+\_\+model\+\_\+set\+\_\+s\+::n\+\_\+models}, and \textbf{ ngram\+\_\+model\+\_\+set\+\_\+s\+::names}.

