\section{include/sphinxbase/ngram\+\_\+model.h File Reference}
\label{ngram__model_8h}\index{include/sphinxbase/ngram\+\_\+model.\+h@{include/sphinxbase/ngram\+\_\+model.\+h}}


N-\/\+Gram language models.  


{\ttfamily \#include $<$stdarg.\+h$>$}\newline
{\ttfamily \#include $<$sphinxbase/sphinxbase\+\_\+export.\+h$>$}\newline
{\ttfamily \#include $<$sphinxbase/prim\+\_\+type.\+h$>$}\newline
{\ttfamily \#include $<$sphinxbase/cmd\+\_\+ln.\+h$>$}\newline
{\ttfamily \#include $<$sphinxbase/logmath.\+h$>$}\newline
{\ttfamily \#include $<$sphinxbase/mmio.\+h$>$}\newline
\subsection*{Macros}
\begin{DoxyCompactItemize}
\item 
\mbox{\label{ngram__model_8h_a3d4b3dddd0ff67e13d30c9bf053d01ab}} 
\#define \textbf{ N\+G\+R\+A\+M\+\_\+\+I\+N\+V\+A\+L\+I\+D\+\_\+\+W\+ID}~-\/1
\begin{DoxyCompactList}\small\item\em Impossible word ID. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Typedefs}
\begin{DoxyCompactItemize}
\item 
\mbox{\label{ngram__model_8h_afaaf0c00e20056d97efcd97e4cae4ea7}} 
typedef struct \textbf{ ngram\+\_\+model\+\_\+s} \textbf{ ngram\+\_\+model\+\_\+t}
\begin{DoxyCompactList}\small\item\em Abstract type representing an N-\/\+Gram based language model. \end{DoxyCompactList}\item 
\mbox{\label{ngram__model_8h_ae36b2f037b2ea751dff23f082379c264}} 
typedef struct \textbf{ ngram\+\_\+class\+\_\+s} \textbf{ ngram\+\_\+class\+\_\+t}
\begin{DoxyCompactList}\small\item\em Abstract type representing a word class in an N-\/\+Gram model. \end{DoxyCompactList}\item 
\mbox{\label{ngram__model_8h_a0e7d02703c48237b2afea436392dcb82}} 
typedef enum \textbf{ ngram\+\_\+file\+\_\+type\+\_\+e} \textbf{ ngram\+\_\+file\+\_\+type\+\_\+t}
\begin{DoxyCompactList}\small\item\em File types for N-\/\+Gram files. \end{DoxyCompactList}\item 
\mbox{\label{ngram__model_8h_ab9b3023d92b99927d1e851108ac3bdad}} 
typedef enum \textbf{ ngram\+\_\+case\+\_\+e} \textbf{ ngram\+\_\+case\+\_\+t}
\begin{DoxyCompactList}\small\item\em Constants for case folding. \end{DoxyCompactList}\item 
\mbox{\label{ngram__model_8h_ac7de090a02fa12a8bba84abb4d5236aa}} 
typedef struct \textbf{ ngram\+\_\+iter\+\_\+s} \textbf{ ngram\+\_\+iter\+\_\+t}
\begin{DoxyCompactList}\small\item\em M-\/gram iterator object. \end{DoxyCompactList}\item 
\mbox{\label{ngram__model_8h_afffd75c5bde8dd84107449468be48547}} 
typedef struct \textbf{ ngram\+\_\+model\+\_\+set\+\_\+iter\+\_\+s} \textbf{ ngram\+\_\+model\+\_\+set\+\_\+iter\+\_\+t}
\begin{DoxyCompactList}\small\item\em Iterator over language models in a set. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Enumerations}
\begin{DoxyCompactItemize}
\item 
enum \textbf{ ngram\+\_\+file\+\_\+type\+\_\+e} \{ \newline
\textbf{ N\+G\+R\+A\+M\+\_\+\+I\+N\+V\+A\+L\+ID} = -\/1, 
\textbf{ N\+G\+R\+A\+M\+\_\+\+A\+U\+TO}, 
\textbf{ N\+G\+R\+A\+M\+\_\+\+A\+R\+PA}, 
\textbf{ N\+G\+R\+A\+M\+\_\+\+D\+MP}, 
\newline
\textbf{ N\+G\+R\+A\+M\+\_\+\+D\+M\+P32}
 \}\begin{DoxyCompactList}\small\item\em File types for N-\/\+Gram files. \end{DoxyCompactList}
\item 
\mbox{\label{ngram__model_8h_aad16a0a1edf29ba8c0df43959c0c4771}} 
enum \textbf{ ngram\+\_\+case\+\_\+e} \{ {\bfseries N\+G\+R\+A\+M\+\_\+\+U\+P\+P\+ER}, 
{\bfseries N\+G\+R\+A\+M\+\_\+\+L\+O\+W\+ER}
 \}\begin{DoxyCompactList}\small\item\em Constants for case folding. \end{DoxyCompactList}
\end{DoxyCompactItemize}
\subsection*{Functions}
\begin{DoxyCompactItemize}
\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT \textbf{ ngram\+\_\+model\+\_\+t} $\ast$ \textbf{ ngram\+\_\+model\+\_\+read} (\textbf{ cmd\+\_\+ln\+\_\+t} $\ast$config, const char $\ast$file\+\_\+name, \textbf{ ngram\+\_\+file\+\_\+type\+\_\+t} file\+\_\+type, \textbf{ logmath\+\_\+t} $\ast$lmath)
\begin{DoxyCompactList}\small\item\em Read an N-\/\+Gram model from a file on disk. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int \textbf{ ngram\+\_\+model\+\_\+write} (\textbf{ ngram\+\_\+model\+\_\+t} $\ast$model, const char $\ast$file\+\_\+name, \textbf{ ngram\+\_\+file\+\_\+type\+\_\+t} format)
\begin{DoxyCompactList}\small\item\em Write an N-\/\+Gram model to disk. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT \textbf{ ngram\+\_\+file\+\_\+type\+\_\+t} \textbf{ ngram\+\_\+file\+\_\+name\+\_\+to\+\_\+type} (const char $\ast$file\+\_\+name)
\begin{DoxyCompactList}\small\item\em Guess the file type for an N-\/\+Gram model from the filename. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT \textbf{ ngram\+\_\+file\+\_\+type\+\_\+t} \textbf{ ngram\+\_\+str\+\_\+to\+\_\+type} (const char $\ast$str\+\_\+name)
\begin{DoxyCompactList}\small\item\em Get the N-\/\+Gram file type from a string. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT char const  $\ast$ \textbf{ ngram\+\_\+type\+\_\+to\+\_\+str} (int type)
\begin{DoxyCompactList}\small\item\em Get the canonical name for an N-\/\+Gram file type. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT \textbf{ ngram\+\_\+model\+\_\+t} $\ast$ \textbf{ ngram\+\_\+model\+\_\+retain} (\textbf{ ngram\+\_\+model\+\_\+t} $\ast$model)
\begin{DoxyCompactList}\small\item\em Retain ownership of an N-\/\+Gram model. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int \textbf{ ngram\+\_\+model\+\_\+free} (\textbf{ ngram\+\_\+model\+\_\+t} $\ast$model)
\begin{DoxyCompactList}\small\item\em Release memory associated with an N-\/\+Gram model. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int \textbf{ ngram\+\_\+model\+\_\+recode} (\textbf{ ngram\+\_\+model\+\_\+t} $\ast$model, const char $\ast$from, const char $\ast$to)
\begin{DoxyCompactList}\small\item\em Re-\/encode word strings in an N-\/\+Gram model. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int \textbf{ ngram\+\_\+model\+\_\+casefold} (\textbf{ ngram\+\_\+model\+\_\+t} $\ast$model, int kase)
\begin{DoxyCompactList}\small\item\em Case-\/fold word strings in an N-\/\+Gram model. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int \textbf{ ngram\+\_\+model\+\_\+apply\+\_\+weights} (\textbf{ ngram\+\_\+model\+\_\+t} $\ast$model, float32 lw, float32 wip, float32 uw)
\begin{DoxyCompactList}\small\item\em Apply a language weight, insertion penalty, and unigram weight to a language model. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT float32 \textbf{ ngram\+\_\+model\+\_\+get\+\_\+weights} (\textbf{ ngram\+\_\+model\+\_\+t} $\ast$model, int32 $\ast$out\+\_\+log\+\_\+wip, int32 $\ast$out\+\_\+log\+\_\+uw)
\begin{DoxyCompactList}\small\item\em Get the current weights from a language model. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 \textbf{ ngram\+\_\+score} (\textbf{ ngram\+\_\+model\+\_\+t} $\ast$model, const char $\ast$word,...)
\begin{DoxyCompactList}\small\item\em Get the score (scaled, interpolated log-\/probability) for a general N-\/\+Gram. \end{DoxyCompactList}\item 
\mbox{\label{ngram__model_8h_a0f8ad53c1a7cab528113b74aad00f15a}} 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 \textbf{ ngram\+\_\+tg\+\_\+score} (\textbf{ ngram\+\_\+model\+\_\+t} $\ast$model, int32 w3, int32 w2, int32 w1, int32 $\ast$n\+\_\+used)
\begin{DoxyCompactList}\small\item\em Quick trigram score lookup. \end{DoxyCompactList}\item 
\mbox{\label{ngram__model_8h_a8c06698fbcb0ef82420088ace045ae81}} 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 \textbf{ ngram\+\_\+bg\+\_\+score} (\textbf{ ngram\+\_\+model\+\_\+t} $\ast$model, int32 w2, int32 w1, int32 $\ast$n\+\_\+used)
\begin{DoxyCompactList}\small\item\em Quick bigram score lookup. \end{DoxyCompactList}\item 
\mbox{\label{ngram__model_8h_a6ac5799e78ea4ad82a11e2439016471e}} 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 \textbf{ ngram\+\_\+ng\+\_\+score} (\textbf{ ngram\+\_\+model\+\_\+t} $\ast$model, int32 wid, int32 $\ast$history, int32 n\+\_\+hist, int32 $\ast$n\+\_\+used)
\begin{DoxyCompactList}\small\item\em Quick general N-\/\+Gram score lookup. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 \textbf{ ngram\+\_\+prob} (\textbf{ ngram\+\_\+model\+\_\+t} $\ast$model, const char $\ast$word,...)
\begin{DoxyCompactList}\small\item\em Get the \char`\"{}raw\char`\"{} log-\/probability for a general N-\/\+Gram. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 \textbf{ ngram\+\_\+ng\+\_\+prob} (\textbf{ ngram\+\_\+model\+\_\+t} $\ast$model, int32 wid, int32 $\ast$history, int32 n\+\_\+hist, int32 $\ast$n\+\_\+used)
\begin{DoxyCompactList}\small\item\em Quick \char`\"{}raw\char`\"{} probability lookup for a general N-\/\+Gram. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 \textbf{ ngram\+\_\+score\+\_\+to\+\_\+prob} (\textbf{ ngram\+\_\+model\+\_\+t} $\ast$model, int32 score)
\begin{DoxyCompactList}\small\item\em Convert score to \char`\"{}raw\char`\"{} log-\/probability. \end{DoxyCompactList}\item 
\mbox{\label{ngram__model_8h_ad03d4355d4ea659815dc25bce8d83880}} 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 \textbf{ ngram\+\_\+wid} (\textbf{ ngram\+\_\+model\+\_\+t} $\ast$model, const char $\ast$word)
\begin{DoxyCompactList}\small\item\em Look up numerical word ID. \end{DoxyCompactList}\item 
\mbox{\label{ngram__model_8h_a96e36290a005c03464ea6c637ccde2f5}} 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT const char $\ast$ \textbf{ ngram\+\_\+word} (\textbf{ ngram\+\_\+model\+\_\+t} $\ast$model, int32 wid)
\begin{DoxyCompactList}\small\item\em Look up word string for numerical word ID. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 \textbf{ ngram\+\_\+unknown\+\_\+wid} (\textbf{ ngram\+\_\+model\+\_\+t} $\ast$model)
\begin{DoxyCompactList}\small\item\em Get the unknown word ID for a language model. \end{DoxyCompactList}\item 
\mbox{\label{ngram__model_8h_ae401a87ad55ae64f286dcd83170f7100}} 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 \textbf{ ngram\+\_\+zero} (\textbf{ ngram\+\_\+model\+\_\+t} $\ast$model)
\begin{DoxyCompactList}\small\item\em Get the \char`\"{}zero\char`\"{} log-\/probability value for a language model. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 \textbf{ ngram\+\_\+model\+\_\+get\+\_\+size} (\textbf{ ngram\+\_\+model\+\_\+t} $\ast$model)
\begin{DoxyCompactList}\small\item\em Get the order of the N-\/gram model (i.\+e. \end{DoxyCompactList}\item 
\mbox{\label{ngram__model_8h_a187531aafc1f11214c9d061f75eae194}} 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 const  $\ast$ \textbf{ ngram\+\_\+model\+\_\+get\+\_\+counts} (\textbf{ ngram\+\_\+model\+\_\+t} $\ast$model)
\begin{DoxyCompactList}\small\item\em Get the counts of the various N-\/grams in the model. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT \textbf{ ngram\+\_\+iter\+\_\+t} $\ast$ \textbf{ ngram\+\_\+model\+\_\+mgrams} (\textbf{ ngram\+\_\+model\+\_\+t} $\ast$model, int m)
\begin{DoxyCompactList}\small\item\em Iterate over all M-\/grams. \end{DoxyCompactList}\item 
\mbox{\label{ngram__model_8h_ad988e0f41447ee404050caf7c7bb7b63}} 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT \textbf{ ngram\+\_\+iter\+\_\+t} $\ast$ \textbf{ ngram\+\_\+iter} (\textbf{ ngram\+\_\+model\+\_\+t} $\ast$model, const char $\ast$word,...)
\begin{DoxyCompactList}\small\item\em Get an iterator over M-\/grams pointing to the specified M-\/gram. \end{DoxyCompactList}\item 
\mbox{\label{ngram__model_8h_a461c6e5914ce463422dfeaeee377e024}} 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT \textbf{ ngram\+\_\+iter\+\_\+t} $\ast$ \textbf{ ngram\+\_\+ng\+\_\+iter} (\textbf{ ngram\+\_\+model\+\_\+t} $\ast$model, int32 wid, int32 $\ast$history, int32 n\+\_\+hist)
\begin{DoxyCompactList}\small\item\em Get an iterator over M-\/grams pointing to the specified M-\/gram. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 const  $\ast$ \textbf{ ngram\+\_\+iter\+\_\+get} (\textbf{ ngram\+\_\+iter\+\_\+t} $\ast$itor, int32 $\ast$out\+\_\+score, int32 $\ast$out\+\_\+bowt)
\begin{DoxyCompactList}\small\item\em Get information from the current M-\/gram in an iterator. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT \textbf{ ngram\+\_\+iter\+\_\+t} $\ast$ \textbf{ ngram\+\_\+iter\+\_\+successors} (\textbf{ ngram\+\_\+iter\+\_\+t} $\ast$itor)
\begin{DoxyCompactList}\small\item\em Iterate over all M-\/gram successors of an M-\/1-\/gram. \end{DoxyCompactList}\item 
\mbox{\label{ngram__model_8h_a3a2b285c01393b3ebddaec1fefed11a4}} 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT \textbf{ ngram\+\_\+iter\+\_\+t} $\ast$ \textbf{ ngram\+\_\+iter\+\_\+next} (\textbf{ ngram\+\_\+iter\+\_\+t} $\ast$itor)
\begin{DoxyCompactList}\small\item\em Advance an M-\/gram iterator. \end{DoxyCompactList}\item 
\mbox{\label{ngram__model_8h_ac9f746c8a5db78ef8b2fb7c312be4a22}} 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT void \textbf{ ngram\+\_\+iter\+\_\+free} (\textbf{ ngram\+\_\+iter\+\_\+t} $\ast$itor)
\begin{DoxyCompactList}\small\item\em Terminate an M-\/gram iterator. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 \textbf{ ngram\+\_\+model\+\_\+add\+\_\+word} (\textbf{ ngram\+\_\+model\+\_\+t} $\ast$model, const char $\ast$word, float32 weight)
\begin{DoxyCompactList}\small\item\em Add a word (unigram) to the language model. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 \textbf{ ngram\+\_\+model\+\_\+read\+\_\+classdef} (\textbf{ ngram\+\_\+model\+\_\+t} $\ast$model, const char $\ast$file\+\_\+name)
\begin{DoxyCompactList}\small\item\em Read a class definition file and add classes to a language model. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 \textbf{ ngram\+\_\+model\+\_\+add\+\_\+class} (\textbf{ ngram\+\_\+model\+\_\+t} $\ast$model, const char $\ast$classname, float32 classweight, char $\ast$$\ast$words, const float32 $\ast$weights, int32 n\+\_\+words)
\begin{DoxyCompactList}\small\item\em Add a new class to a language model. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 \textbf{ ngram\+\_\+model\+\_\+add\+\_\+class\+\_\+word} (\textbf{ ngram\+\_\+model\+\_\+t} $\ast$model, const char $\ast$classname, const char $\ast$word, float32 weight)
\begin{DoxyCompactList}\small\item\em Add a word to a class in a language model. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT \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 I\+Ds. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT \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 
\mbox{\label{ngram__model_8h_a22b8f5f49231b4aef3d5a166ea7155b6}} 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 \textbf{ ngram\+\_\+model\+\_\+set\+\_\+count} (\textbf{ ngram\+\_\+model\+\_\+t} $\ast$set)
\begin{DoxyCompactList}\small\item\em Returns the number of language models in a set. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT \textbf{ ngram\+\_\+model\+\_\+set\+\_\+iter\+\_\+t} $\ast$ \textbf{ ngram\+\_\+model\+\_\+set\+\_\+iter} (\textbf{ ngram\+\_\+model\+\_\+t} $\ast$set)
\begin{DoxyCompactList}\small\item\em Begin iterating over language models in a set. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT \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 
\mbox{\label{ngram__model_8h_ae5b58f360ab6432528ffaead1d2b2a2d}} 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT 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 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT \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 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT \textbf{ ngram\+\_\+model\+\_\+t} $\ast$ \textbf{ ngram\+\_\+model\+\_\+set\+\_\+select} (\textbf{ ngram\+\_\+model\+\_\+t} $\ast$set, const char $\ast$name)
\begin{DoxyCompactList}\small\item\em Select a single language model from a set for scoring. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT \textbf{ ngram\+\_\+model\+\_\+t} $\ast$ \textbf{ ngram\+\_\+model\+\_\+set\+\_\+lookup} (\textbf{ ngram\+\_\+model\+\_\+t} $\ast$set, const char $\ast$name)
\begin{DoxyCompactList}\small\item\em Look up a language model by name from a set. \end{DoxyCompactList}\item 
\mbox{\label{ngram__model_8h_a95a4da1562cb6d67a01a733bd0bbb436}} 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT const char $\ast$ \textbf{ ngram\+\_\+model\+\_\+set\+\_\+current} (\textbf{ ngram\+\_\+model\+\_\+t} $\ast$set)
\begin{DoxyCompactList}\small\item\em Get the current language model name, if any. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT \textbf{ ngram\+\_\+model\+\_\+t} $\ast$ \textbf{ ngram\+\_\+model\+\_\+set\+\_\+interp} (\textbf{ ngram\+\_\+model\+\_\+t} $\ast$set, 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 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT \textbf{ ngram\+\_\+model\+\_\+t} $\ast$ \textbf{ ngram\+\_\+model\+\_\+set\+\_\+add} (\textbf{ ngram\+\_\+model\+\_\+t} $\ast$set, \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 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT \textbf{ ngram\+\_\+model\+\_\+t} $\ast$ \textbf{ ngram\+\_\+model\+\_\+set\+\_\+remove} (\textbf{ ngram\+\_\+model\+\_\+t} $\ast$set, const char $\ast$name, int reuse\+\_\+widmap)
\begin{DoxyCompactList}\small\item\em Remove a language model from a set. \end{DoxyCompactList}\item 
\mbox{\label{ngram__model_8h_a3e8abe87ae12cfbe1b79fd99213abe2d}} 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT void \textbf{ ngram\+\_\+model\+\_\+set\+\_\+map\+\_\+words} (\textbf{ ngram\+\_\+model\+\_\+t} $\ast$set, 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}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 \textbf{ ngram\+\_\+model\+\_\+set\+\_\+current\+\_\+wid} (\textbf{ ngram\+\_\+model\+\_\+t} $\ast$set, int32 set\+\_\+wid)
\begin{DoxyCompactList}\small\item\em Query the word-\/\+ID mapping for the current language model. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 \textbf{ ngram\+\_\+model\+\_\+set\+\_\+known\+\_\+wid} (\textbf{ ngram\+\_\+model\+\_\+t} $\ast$set, 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 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT void \textbf{ ngram\+\_\+model\+\_\+flush} (\textbf{ ngram\+\_\+model\+\_\+t} $\ast$lm)
\begin{DoxyCompactList}\small\item\em Flush any cached N-\/\+Gram information. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Detailed Description}
N-\/\+Gram language models. 

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


\subsection{Enumeration Type Documentation}
\mbox{\label{ngram__model_8h_a406c0d64c15a9d1749d07c8ab6e0ae74}} 
\index{ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}!ngram\+\_\+file\+\_\+type\+\_\+e@{ngram\+\_\+file\+\_\+type\+\_\+e}}
\index{ngram\+\_\+file\+\_\+type\+\_\+e@{ngram\+\_\+file\+\_\+type\+\_\+e}!ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}}
\subsubsection{ngram\+\_\+file\+\_\+type\+\_\+e}
{\footnotesize\ttfamily enum \textbf{ ngram\+\_\+file\+\_\+type\+\_\+e}}



File types for N-\/\+Gram files. 

\begin{DoxyEnumFields}{Enumerator}
\raisebox{\heightof{T}}[0pt][0pt]{\index{N\+G\+R\+A\+M\+\_\+\+I\+N\+V\+A\+L\+ID@{N\+G\+R\+A\+M\+\_\+\+I\+N\+V\+A\+L\+ID}!ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}}\index{ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}!N\+G\+R\+A\+M\+\_\+\+I\+N\+V\+A\+L\+ID@{N\+G\+R\+A\+M\+\_\+\+I\+N\+V\+A\+L\+ID}}}\mbox{\label{ngram__model_8h_a406c0d64c15a9d1749d07c8ab6e0ae74a2cf596c8b0c63a3a0ba1fe33326cc796}} 
N\+G\+R\+A\+M\+\_\+\+I\+N\+V\+A\+L\+ID&Not a valid file type. \\
\hline

\raisebox{\heightof{T}}[0pt][0pt]{\index{N\+G\+R\+A\+M\+\_\+\+A\+U\+TO@{N\+G\+R\+A\+M\+\_\+\+A\+U\+TO}!ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}}\index{ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}!N\+G\+R\+A\+M\+\_\+\+A\+U\+TO@{N\+G\+R\+A\+M\+\_\+\+A\+U\+TO}}}\mbox{\label{ngram__model_8h_a406c0d64c15a9d1749d07c8ab6e0ae74a441701bf8ae0a2b79716feb31b5f257a}} 
N\+G\+R\+A\+M\+\_\+\+A\+U\+TO&Determine file type automatically. \\
\hline

\raisebox{\heightof{T}}[0pt][0pt]{\index{N\+G\+R\+A\+M\+\_\+\+A\+R\+PA@{N\+G\+R\+A\+M\+\_\+\+A\+R\+PA}!ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}}\index{ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}!N\+G\+R\+A\+M\+\_\+\+A\+R\+PA@{N\+G\+R\+A\+M\+\_\+\+A\+R\+PA}}}\mbox{\label{ngram__model_8h_a406c0d64c15a9d1749d07c8ab6e0ae74a77ef2341d826b3cc8b836e3af1efba99}} 
N\+G\+R\+A\+M\+\_\+\+A\+R\+PA&A\+R\+P\+A\+BO text format (the standard). \\
\hline

\raisebox{\heightof{T}}[0pt][0pt]{\index{N\+G\+R\+A\+M\+\_\+\+D\+MP@{N\+G\+R\+A\+M\+\_\+\+D\+MP}!ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}}\index{ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}!N\+G\+R\+A\+M\+\_\+\+D\+MP@{N\+G\+R\+A\+M\+\_\+\+D\+MP}}}\mbox{\label{ngram__model_8h_a406c0d64c15a9d1749d07c8ab6e0ae74addfc3620d0fbc6f05f7f8e455245dd92}} 
N\+G\+R\+A\+M\+\_\+\+D\+MP&Sphinx .D\+MP format. \\
\hline

\raisebox{\heightof{T}}[0pt][0pt]{\index{N\+G\+R\+A\+M\+\_\+\+D\+M\+P32@{N\+G\+R\+A\+M\+\_\+\+D\+M\+P32}!ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}}\index{ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}!N\+G\+R\+A\+M\+\_\+\+D\+M\+P32@{N\+G\+R\+A\+M\+\_\+\+D\+M\+P32}}}\mbox{\label{ngram__model_8h_a406c0d64c15a9d1749d07c8ab6e0ae74ab8fe83d2dec88c1c8cb4d82a8a528bb8}} 
N\+G\+R\+A\+M\+\_\+\+D\+M\+P32&Sphinx .D\+M\+P32 format (N\+OT S\+U\+P\+P\+O\+R\+T\+ED) \\
\hline

\end{DoxyEnumFields}


Definition at line 76 of file ngram\+\_\+model.\+h.



\subsection{Function Documentation}
\mbox{\label{ngram__model_8h_ad758d3f491d501bdec2ada8088e9b656}} 
\index{ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}!ngram\+\_\+file\+\_\+name\+\_\+to\+\_\+type@{ngram\+\_\+file\+\_\+name\+\_\+to\+\_\+type}}
\index{ngram\+\_\+file\+\_\+name\+\_\+to\+\_\+type@{ngram\+\_\+file\+\_\+name\+\_\+to\+\_\+type}!ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}}
\subsubsection{ngram\+\_\+file\+\_\+name\+\_\+to\+\_\+type()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT \textbf{ ngram\+\_\+file\+\_\+type\+\_\+t} ngram\+\_\+file\+\_\+name\+\_\+to\+\_\+type (\begin{DoxyParamCaption}\item[{const char $\ast$}]{file\+\_\+name }\end{DoxyParamCaption})}



Guess the file type for an N-\/\+Gram model from the filename. 

\begin{DoxyReturn}{Returns}
the guessed file type, or N\+G\+R\+A\+M\+\_\+\+I\+N\+V\+A\+L\+ID if none could be guessed. 
\end{DoxyReturn}


Definition at line 64 of file ngram\+\_\+model.\+c.



Referenced by ngram\+\_\+model\+\_\+write().

\mbox{\label{ngram__model_8h_a240c738781daa226a2fc13395dbdb514}} 
\index{ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}!ngram\+\_\+iter\+\_\+get@{ngram\+\_\+iter\+\_\+get}}
\index{ngram\+\_\+iter\+\_\+get@{ngram\+\_\+iter\+\_\+get}!ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}}
\subsubsection{ngram\+\_\+iter\+\_\+get()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 const$\ast$ ngram\+\_\+iter\+\_\+get (\begin{DoxyParamCaption}\item[{\textbf{ ngram\+\_\+iter\+\_\+t} $\ast$}]{itor,  }\item[{int32 $\ast$}]{out\+\_\+score,  }\item[{int32 $\ast$}]{out\+\_\+bowt }\end{DoxyParamCaption})}



Get information from the current M-\/gram in an iterator. 


\begin{DoxyParams}{Parameters}
{\em out\+\_\+score} & Output\+: Score for this M-\/gram (including any word penalty and language weight). \\
\hline
{\em out\+\_\+bowt} & Output\+: Backoff weight for this M-\/gram. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
read-\/only array of word I\+Ds. 
\end{DoxyReturn}


Definition at line 750 of file ngram\+\_\+model.\+c.



References ngram\+\_\+model\+\_\+s\+::funcs, and ngram\+\_\+funcs\+\_\+s\+::iter\+\_\+get.

\mbox{\label{ngram__model_8h_ae85f41e2defc5b65b12026d29cd4fdaa}} 
\index{ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}!ngram\+\_\+iter\+\_\+successors@{ngram\+\_\+iter\+\_\+successors}}
\index{ngram\+\_\+iter\+\_\+successors@{ngram\+\_\+iter\+\_\+successors}!ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}}
\subsubsection{ngram\+\_\+iter\+\_\+successors()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT \textbf{ ngram\+\_\+iter\+\_\+t}$\ast$ ngram\+\_\+iter\+\_\+successors (\begin{DoxyParamCaption}\item[{\textbf{ ngram\+\_\+iter\+\_\+t} $\ast$}]{itor }\end{DoxyParamCaption})}



Iterate over all M-\/gram successors of an M-\/1-\/gram. 


\begin{DoxyParams}{Parameters}
{\em itor} & Iterator pointing to the M-\/1-\/gram to get successors of. \\
\hline
\end{DoxyParams}


Definition at line 741 of file ngram\+\_\+model.\+c.



References ngram\+\_\+iter\+\_\+s\+::m, and ngram\+\_\+model\+\_\+s\+::n.

\mbox{\label{ngram__model_8h_a0481b03a2bf03ef0a197da0a1f7d1caa}} 
\index{ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}!ngram\+\_\+model\+\_\+add\+\_\+class@{ngram\+\_\+model\+\_\+add\+\_\+class}}
\index{ngram\+\_\+model\+\_\+add\+\_\+class@{ngram\+\_\+model\+\_\+add\+\_\+class}!ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}}
\subsubsection{ngram\+\_\+model\+\_\+add\+\_\+class()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 ngram\+\_\+model\+\_\+add\+\_\+class (\begin{DoxyParamCaption}\item[{\textbf{ ngram\+\_\+model\+\_\+t} $\ast$}]{model,  }\item[{const char $\ast$}]{classname,  }\item[{float32}]{classweight,  }\item[{char $\ast$$\ast$}]{words,  }\item[{const float32 $\ast$}]{weights,  }\item[{int32}]{n\+\_\+words }\end{DoxyParamCaption})}



Add a new class to a language model. 

If {\ttfamily classname} already exists in the unigram set for {\ttfamily model}, then it will be converted to a class tag, and {\ttfamily classweight} will be ignored. Otherwise, a new unigram will be created as in \doxyref{ngram\+\_\+model\+\_\+add\+\_\+word()}{p.}{ngram__model_8h_a38e034d58ee0d6a4c0dd6f852cb71c3c}. 

Definition at line 1005 of file ngram\+\_\+model.\+c.

\mbox{\label{ngram__model_8h_a39eabb4994cf99c4bc2116e12af0c9f1}} 
\index{ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}!ngram\+\_\+model\+\_\+add\+\_\+class\+\_\+word@{ngram\+\_\+model\+\_\+add\+\_\+class\+\_\+word}}
\index{ngram\+\_\+model\+\_\+add\+\_\+class\+\_\+word@{ngram\+\_\+model\+\_\+add\+\_\+class\+\_\+word}!ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}}
\subsubsection{ngram\+\_\+model\+\_\+add\+\_\+class\+\_\+word()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 ngram\+\_\+model\+\_\+add\+\_\+class\+\_\+word (\begin{DoxyParamCaption}\item[{\textbf{ ngram\+\_\+model\+\_\+t} $\ast$}]{model,  }\item[{const char $\ast$}]{classname,  }\item[{const char $\ast$}]{word,  }\item[{float32}]{weight }\end{DoxyParamCaption})}



Add a word to a class in a language model. 


\begin{DoxyParams}{Parameters}
{\em model} & The model to add a word to. \\
\hline
{\em classname} & Name of the class to add this word to. \\
\hline
{\em word} & Text of the word to add. \\
\hline
{\em weight} & Weight of this word relative to the within-\/class uniform distribution. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The word ID for the new word. 
\end{DoxyReturn}


Definition at line 955 of file ngram\+\_\+model.\+c.



References ngram\+\_\+model\+\_\+s\+::classes, E\+\_\+\+E\+R\+R\+OR, ngram\+\_\+model\+\_\+s\+::lmath, logmath\+\_\+log(), ngram\+\_\+model\+\_\+s\+::n\+\_\+classes, ngram\+\_\+class\+\_\+s\+::n\+\_\+hash, ngram\+\_\+class\+\_\+s\+::n\+\_\+hash\+\_\+inuse, ngram\+\_\+class\+\_\+s\+::n\+\_\+words, N\+G\+R\+A\+M\+\_\+\+I\+N\+V\+A\+L\+I\+D\+\_\+\+W\+ID, ngram\+\_\+wid(), ngram\+\_\+class\+\_\+s\+::prob1, ngram\+\_\+class\+\_\+s\+::ngram\+\_\+hash\+\_\+s\+::prob1, ngram\+\_\+class\+\_\+s\+::tag\+\_\+wid, and ngram\+\_\+class\+\_\+s\+::ngram\+\_\+hash\+\_\+s\+::wid.

\mbox{\label{ngram__model_8h_a38e034d58ee0d6a4c0dd6f852cb71c3c}} 
\index{ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}!ngram\+\_\+model\+\_\+add\+\_\+word@{ngram\+\_\+model\+\_\+add\+\_\+word}}
\index{ngram\+\_\+model\+\_\+add\+\_\+word@{ngram\+\_\+model\+\_\+add\+\_\+word}!ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}}
\subsubsection{ngram\+\_\+model\+\_\+add\+\_\+word()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 ngram\+\_\+model\+\_\+add\+\_\+word (\begin{DoxyParamCaption}\item[{\textbf{ ngram\+\_\+model\+\_\+t} $\ast$}]{model,  }\item[{const char $\ast$}]{word,  }\item[{float32}]{weight }\end{DoxyParamCaption})}



Add a word (unigram) to the language model. 

\begin{DoxyNote}{Note}
The semantics of this are not particularly well-\/defined for model sets, and may be subject to change. Currently this will add the word to all of the submodels
\end{DoxyNote}

\begin{DoxyParams}{Parameters}
{\em model} & The model to add a word to. \\
\hline
{\em word} & Text of the word to add. \\
\hline
{\em weight} & Weight of this word relative to the uniform distribution. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The word ID for the new word. 
\end{DoxyReturn}


Definition at line 832 of file ngram\+\_\+model.\+c.



References ngram\+\_\+funcs\+\_\+s\+::add\+\_\+ug, ckd\+\_\+calloc, E\+\_\+\+W\+A\+RN, ngram\+\_\+model\+\_\+s\+::funcs, glist\+\_\+count(), ngram\+\_\+model\+\_\+s\+::lmath, ngram\+\_\+model\+\_\+s\+::log\+\_\+zero, logmath\+\_\+log(), ngram\+\_\+class\+\_\+s\+::n\+\_\+words, N\+G\+R\+A\+M\+\_\+\+I\+N\+V\+A\+L\+I\+D\+\_\+\+W\+ID, ngram\+\_\+class\+\_\+s\+::prob1, ngram\+\_\+class\+\_\+s\+::start\+\_\+wid, ngram\+\_\+class\+\_\+s\+::tag\+\_\+wid, and ngram\+\_\+model\+\_\+s\+::writable.

\mbox{\label{ngram__model_8h_aa4b8d7c1f3d873b8458c0cfee13af4da}} 
\index{ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}!ngram\+\_\+model\+\_\+apply\+\_\+weights@{ngram\+\_\+model\+\_\+apply\+\_\+weights}}
\index{ngram\+\_\+model\+\_\+apply\+\_\+weights@{ngram\+\_\+model\+\_\+apply\+\_\+weights}!ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}}
\subsubsection{ngram\+\_\+model\+\_\+apply\+\_\+weights()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int ngram\+\_\+model\+\_\+apply\+\_\+weights (\begin{DoxyParamCaption}\item[{\textbf{ ngram\+\_\+model\+\_\+t} $\ast$}]{model,  }\item[{float32}]{lw,  }\item[{float32}]{wip,  }\item[{float32}]{uw }\end{DoxyParamCaption})}



Apply a language weight, insertion penalty, and unigram weight to a language model. 

This will change the values output by \doxyref{ngram\+\_\+score()}{p.}{ngram__model_8h_a9c23d79885af400e17ac2a1b7169660d} and friends. This is done for efficiency since in decoding, these are the only values we actually need. Call \doxyref{ngram\+\_\+prob()}{p.}{ngram__model_8h_a68cfda3f503e1a4a87f08aa5a3a5ea88} if you want the \char`\"{}raw\char`\"{} N-\/\+Gram probability estimate.

To remove all weighting, call ngram\+\_\+apply\+\_\+weights(model, 1.\+0, 1.\+0, 1.\+0). 

Definition at line 477 of file ngram\+\_\+model.\+c.



References ngram\+\_\+funcs\+\_\+s\+::apply\+\_\+weights, and ngram\+\_\+model\+\_\+s\+::funcs.

\mbox{\label{ngram__model_8h_a41b938a2c4b129dc0df37b2312d65506}} 
\index{ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}!ngram\+\_\+model\+\_\+casefold@{ngram\+\_\+model\+\_\+casefold}}
\index{ngram\+\_\+model\+\_\+casefold@{ngram\+\_\+model\+\_\+casefold}!ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}}
\subsubsection{ngram\+\_\+model\+\_\+casefold()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int ngram\+\_\+model\+\_\+casefold (\begin{DoxyParamCaption}\item[{\textbf{ ngram\+\_\+model\+\_\+t} $\ast$}]{model,  }\item[{int}]{kase }\end{DoxyParamCaption})}



Case-\/fold word strings in an N-\/\+Gram model. 

W\+A\+R\+N\+I\+NG\+: This is not Unicode aware, so any non-\/\+A\+S\+C\+II characters will not be converted. 

Definition at line 299 of file ngram\+\_\+model.\+c.



References ngram\+\_\+model\+\_\+s\+::writable.

\mbox{\label{ngram__model_8h_a8304f56d82278824b0a94c254d7235aa}} 
\index{ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}!ngram\+\_\+model\+\_\+flush@{ngram\+\_\+model\+\_\+flush}}
\index{ngram\+\_\+model\+\_\+flush@{ngram\+\_\+model\+\_\+flush}!ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}}
\subsubsection{ngram\+\_\+model\+\_\+flush()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT void ngram\+\_\+model\+\_\+flush (\begin{DoxyParamCaption}\item[{\textbf{ ngram\+\_\+model\+\_\+t} $\ast$}]{lm }\end{DoxyParamCaption})}



Flush any cached N-\/\+Gram information. 

Some types of models cache trigram or other N-\/\+Gram information to speed repeated access to N-\/\+Grams with shared histories. This function flushes the cache so as to avoid dynamic memory leaks. 

Definition at line 247 of file ngram\+\_\+model.\+c.



References ngram\+\_\+funcs\+\_\+s\+::flush, and ngram\+\_\+model\+\_\+s\+::funcs.

\mbox{\label{ngram__model_8h_aec73d28e7285e539a0b44a7ac0cbe489}} 
\index{ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}!ngram\+\_\+model\+\_\+free@{ngram\+\_\+model\+\_\+free}}
\index{ngram\+\_\+model\+\_\+free@{ngram\+\_\+model\+\_\+free}!ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}}
\subsubsection{ngram\+\_\+model\+\_\+free()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int ngram\+\_\+model\+\_\+free (\begin{DoxyParamCaption}\item[{\textbf{ ngram\+\_\+model\+\_\+t} $\ast$}]{model }\end{DoxyParamCaption})}



Release memory associated with an N-\/\+Gram model. 

\begin{DoxyReturn}{Returns}
new reference count (0 if freed completely) 
\end{DoxyReturn}


Definition at line 254 of file ngram\+\_\+model.\+c.

\mbox{\label{ngram__model_8h_a462d374099a4fe8b3c3195b5e2013545}} 
\index{ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}!ngram\+\_\+model\+\_\+get\+\_\+size@{ngram\+\_\+model\+\_\+get\+\_\+size}}
\index{ngram\+\_\+model\+\_\+get\+\_\+size@{ngram\+\_\+model\+\_\+get\+\_\+size}!ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}}
\subsubsection{ngram\+\_\+model\+\_\+get\+\_\+size()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 ngram\+\_\+model\+\_\+get\+\_\+size (\begin{DoxyParamCaption}\item[{\textbf{ ngram\+\_\+model\+\_\+t} $\ast$}]{model }\end{DoxyParamCaption})}



Get the order of the N-\/gram model (i.\+e. 

the \char`\"{}\+N\char`\"{} in \char`\"{}\+N-\/gram\char`\"{}) 

Definition at line 663 of file ngram\+\_\+model.\+c.

\mbox{\label{ngram__model_8h_a30170c1307e065e1f7159a04f75df304}} 
\index{ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}!ngram\+\_\+model\+\_\+get\+\_\+weights@{ngram\+\_\+model\+\_\+get\+\_\+weights}}
\index{ngram\+\_\+model\+\_\+get\+\_\+weights@{ngram\+\_\+model\+\_\+get\+\_\+weights}!ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}}
\subsubsection{ngram\+\_\+model\+\_\+get\+\_\+weights()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT float32 ngram\+\_\+model\+\_\+get\+\_\+weights (\begin{DoxyParamCaption}\item[{\textbf{ ngram\+\_\+model\+\_\+t} $\ast$}]{model,  }\item[{int32 $\ast$}]{out\+\_\+log\+\_\+wip,  }\item[{int32 $\ast$}]{out\+\_\+log\+\_\+uw }\end{DoxyParamCaption})}



Get the current weights from a language model. 


\begin{DoxyParams}{Parameters}
{\em model} & The model in question. \\
\hline
{\em out\+\_\+log\+\_\+wip} & Output\+: (optional) logarithm of word insertion penalty. \\
\hline
{\em out\+\_\+log\+\_\+uw} & Output\+: (optional) logarithm of unigram weight. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
language weight. 
\end{DoxyReturn}


Definition at line 484 of file ngram\+\_\+model.\+c.



References ngram\+\_\+model\+\_\+s\+::log\+\_\+uw, ngram\+\_\+model\+\_\+s\+::log\+\_\+wip, and ngram\+\_\+model\+\_\+s\+::lw.

\mbox{\label{ngram__model_8h_a12683dda2253dc45680102f02fbdb1e2}} 
\index{ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}!ngram\+\_\+model\+\_\+mgrams@{ngram\+\_\+model\+\_\+mgrams}}
\index{ngram\+\_\+model\+\_\+mgrams@{ngram\+\_\+model\+\_\+mgrams}!ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}}
\subsubsection{ngram\+\_\+model\+\_\+mgrams()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT \textbf{ ngram\+\_\+iter\+\_\+t}$\ast$ ngram\+\_\+model\+\_\+mgrams (\begin{DoxyParamCaption}\item[{\textbf{ ngram\+\_\+model\+\_\+t} $\ast$}]{model,  }\item[{int}]{m }\end{DoxyParamCaption})}



Iterate over all M-\/grams. 


\begin{DoxyParams}{Parameters}
{\em model} & Language model to query. \\
\hline
{\em m} & Order of the M-\/\+Grams requested minus one (i.\+e. order of the history) \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
An iterator over the requested M, or N\+U\+LL if no N-\/grams of order M+1 exist. 
\end{DoxyReturn}


Definition at line 689 of file ngram\+\_\+model.\+c.



References ngram\+\_\+model\+\_\+s\+::n.

\mbox{\label{ngram__model_8h_ab0c840f2bdfc38cea08bb70054f76624}} 
\index{ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}!ngram\+\_\+model\+\_\+read@{ngram\+\_\+model\+\_\+read}}
\index{ngram\+\_\+model\+\_\+read@{ngram\+\_\+model\+\_\+read}!ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}}
\subsubsection{ngram\+\_\+model\+\_\+read()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT \textbf{ ngram\+\_\+model\+\_\+t}$\ast$ ngram\+\_\+model\+\_\+read (\begin{DoxyParamCaption}\item[{\textbf{ cmd\+\_\+ln\+\_\+t} $\ast$}]{config,  }\item[{const char $\ast$}]{file\+\_\+name,  }\item[{\textbf{ ngram\+\_\+file\+\_\+type\+\_\+t}}]{file\+\_\+type,  }\item[{\textbf{ logmath\+\_\+t} $\ast$}]{lmath }\end{DoxyParamCaption})}



Read an N-\/\+Gram model from a file on disk. 


\begin{DoxyParams}{Parameters}
{\em config} & Optional pointer to a set of command-\/line arguments. Recognized arguments are\+:\\
\hline
\end{DoxyParams}

\begin{DoxyItemize}
\item -\/mmap (boolean) whether to use memory-\/mapped I/O
\item -\/lw (float32) language weight to apply to the model
\item -\/wip (float32) word insertion penalty to apply to the model
\item -\/uw (float32) unigram weight to apply to the model
\end{DoxyItemize}


\begin{DoxyParams}{Parameters}
{\em file\+\_\+name} & path to the file to read. \\
\hline
{\em file\+\_\+type} & type of the file, or N\+G\+R\+A\+M\+\_\+\+A\+U\+TO to determine automatically. \\
\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_a1c1b2ba3b137a39e9e835a8f3e27d381}. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
newly created ngram\+\_\+model\+\_\+t. 
\end{DoxyReturn}


Definition at line 121 of file ngram\+\_\+model.\+c.

\mbox{\label{ngram__model_8h_a9b2a86c23543158754373c5456fe890d}} 
\index{ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}!ngram\+\_\+model\+\_\+read\+\_\+classdef@{ngram\+\_\+model\+\_\+read\+\_\+classdef}}
\index{ngram\+\_\+model\+\_\+read\+\_\+classdef@{ngram\+\_\+model\+\_\+read\+\_\+classdef}!ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}}
\subsubsection{ngram\+\_\+model\+\_\+read\+\_\+classdef()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 ngram\+\_\+model\+\_\+read\+\_\+classdef (\begin{DoxyParamCaption}\item[{\textbf{ ngram\+\_\+model\+\_\+t} $\ast$}]{model,  }\item[{const char $\ast$}]{file\+\_\+name }\end{DoxyParamCaption})}



Read a class definition file and add classes to a language model. 

This function assumes that the class tags have already been defined as unigrams in the language model. All words in the class definition will be added to the lexicon as special in-\/class words. For this reason is is necessary that they not have the same names as any words in the general unigram distribution. The convention is to suffix them with \char`\"{}\+:class\+\_\+tag\char`\"{}, where class\+\_\+tag is the class tag minus the enclosing square brackets.

\begin{DoxyReturn}{Returns}
0 for success, $<$0 for error 
\end{DoxyReturn}


Definition at line 1199 of file ngram\+\_\+model.\+c.

\mbox{\label{ngram__model_8h_aac2b3fd054597c2fdfbb59db97d72ec0}} 
\index{ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}!ngram\+\_\+model\+\_\+recode@{ngram\+\_\+model\+\_\+recode}}
\index{ngram\+\_\+model\+\_\+recode@{ngram\+\_\+model\+\_\+recode}!ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}}
\subsubsection{ngram\+\_\+model\+\_\+recode()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int ngram\+\_\+model\+\_\+recode (\begin{DoxyParamCaption}\item[{\textbf{ ngram\+\_\+model\+\_\+t} $\ast$}]{model,  }\item[{const char $\ast$}]{from,  }\item[{const char $\ast$}]{to }\end{DoxyParamCaption})}



Re-\/encode word strings in an N-\/\+Gram model. 

Character set names are the same as those passed to iconv(1). If your system does not have iconv, this function may fail. Also, because all file formats consist of 8-\/bit character streams, attempting to convert to or from U\+T\+F-\/16 (or any other encoding which contains null bytes) is a recipe for total desaster.

We have no interest in supporting U\+T\+F-\/16, so don\textquotesingle{}t ask.

Note that this does not affect any pronunciation dictionary you might currently be using in conjunction with this N-\/\+Gram model, so the effect of calling this during decoding is undefined. That\textquotesingle{}s a bug! 

Definition at line 470 of file ngram\+\_\+model.\+c.

\mbox{\label{ngram__model_8h_a046e6ff8cd8787e412400534a9649a81}} 
\index{ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}!ngram\+\_\+model\+\_\+retain@{ngram\+\_\+model\+\_\+retain}}
\index{ngram\+\_\+model\+\_\+retain@{ngram\+\_\+model\+\_\+retain}!ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}}
\subsubsection{ngram\+\_\+model\+\_\+retain()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT \textbf{ ngram\+\_\+model\+\_\+t}$\ast$ ngram\+\_\+model\+\_\+retain (\begin{DoxyParamCaption}\item[{\textbf{ ngram\+\_\+model\+\_\+t} $\ast$}]{model }\end{DoxyParamCaption})}



Retain ownership of an N-\/\+Gram model. 

\begin{DoxyReturn}{Returns}
Pointer to retained model. 
\end{DoxyReturn}


Definition at line 239 of file ngram\+\_\+model.\+c.



References ngram\+\_\+model\+\_\+s\+::refcount.

\mbox{\label{ngram__model_8h_aab34758e97f75733330f3f4cff8a5311}} 
\index{ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}!ngram\+\_\+model\+\_\+set\+\_\+add@{ngram\+\_\+model\+\_\+set\+\_\+add}}
\index{ngram\+\_\+model\+\_\+set\+\_\+add@{ngram\+\_\+model\+\_\+set\+\_\+add}!ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}}
\subsubsection{ngram\+\_\+model\+\_\+set\+\_\+add()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT \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 520 of file ngram\+\_\+model\+\_\+set.\+c.



References ckd\+\_\+calloc\+\_\+2d, ckd\+\_\+free\+\_\+2d(), ckd\+\_\+realloc, ckd\+\_\+salloc, ngram\+\_\+model\+\_\+s\+::lmath, logmath\+\_\+log(), ngram\+\_\+model\+\_\+s\+::n, ngram\+\_\+model\+\_\+s\+::n\+\_\+words, ngram\+\_\+wid(), and ngram\+\_\+model\+\_\+s\+::word\+\_\+str.

\mbox{\label{ngram__model_8h_af783553aa7527b7544d093aaea74d97a}} 
\index{ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}!ngram\+\_\+model\+\_\+set\+\_\+current\+\_\+wid@{ngram\+\_\+model\+\_\+set\+\_\+current\+\_\+wid}}
\index{ngram\+\_\+model\+\_\+set\+\_\+current\+\_\+wid@{ngram\+\_\+model\+\_\+set\+\_\+current\+\_\+wid}!ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}}
\subsubsection{ngram\+\_\+model\+\_\+set\+\_\+current\+\_\+wid()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT 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 N\+G\+R\+A\+M\+\_\+\+I\+N\+V\+A\+L\+I\+D\+\_\+\+W\+ID if {\ttfamily set\+\_\+wid} is invalid or interpolation is enabled. 
\end{DoxyReturn}


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



References ngram\+\_\+model\+\_\+s\+::n\+\_\+words, and N\+G\+R\+A\+M\+\_\+\+I\+N\+V\+A\+L\+I\+D\+\_\+\+W\+ID.

\mbox{\label{ngram__model_8h_a02310e01a48928e1d430aef0ea3c9a99}} 
\index{ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}!ngram\+\_\+model\+\_\+set\+\_\+init@{ngram\+\_\+model\+\_\+set\+\_\+init}}
\index{ngram\+\_\+model\+\_\+set\+\_\+init@{ngram\+\_\+model\+\_\+set\+\_\+init}!ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}}
\subsubsection{ngram\+\_\+model\+\_\+set\+\_\+init()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT \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 I\+Ds. 

This function creates a meta-\/language model which groups together a set of language models, synchronizing word I\+Ds 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_a5e7a3fd20d32783ce07b760781f658f8}, or interpolate between scores from all models. To do the latter, you can either pass a non-\/\+N\+U\+LL value of the {\ttfamily weights} parameter, or re-\/activate interpolation later on by calling \doxyref{ngram\+\_\+model\+\_\+set\+\_\+interp()}{p.}{ngram__model_8h_a8a4c853e77c6b48face3a781480e77d6}.

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 L\+Ms. \\
\hline
{\em weights} & Array of weights to use in interpolating L\+Ms, or N\+U\+LL for no interpolation. \\
\hline
{\em n\+\_\+models} & Number of elements in the arrays passed to this function. \\
\hline
\end{DoxyParams}


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

\mbox{\label{ngram__model_8h_a8a4c853e77c6b48face3a781480e77d6}} 
\index{ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}!ngram\+\_\+model\+\_\+set\+\_\+interp@{ngram\+\_\+model\+\_\+set\+\_\+interp}}
\index{ngram\+\_\+model\+\_\+set\+\_\+interp@{ngram\+\_\+model\+\_\+set\+\_\+interp}!ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}}
\subsubsection{ngram\+\_\+model\+\_\+set\+\_\+interp()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT \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 N\+U\+LL, any previously initialized set of weights will be used. If no weights were specified to \doxyref{ngram\+\_\+model\+\_\+set\+\_\+init()}{p.}{ngram__model_8h_a02310e01a48928e1d430aef0ea3c9a99}, then a uniform distribution will be used. 

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



References E\+\_\+\+E\+R\+R\+OR.

\mbox{\label{ngram__model_8h_a880c7768b082a124e1b6f6f1a764b1e3}} 
\index{ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}!ngram\+\_\+model\+\_\+set\+\_\+iter@{ngram\+\_\+model\+\_\+set\+\_\+iter}}
\index{ngram\+\_\+model\+\_\+set\+\_\+iter@{ngram\+\_\+model\+\_\+set\+\_\+iter}!ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}}
\subsubsection{ngram\+\_\+model\+\_\+set\+\_\+iter()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT \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 N\+U\+LL if no models remain. 
\end{DoxyReturn}


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

\mbox{\label{ngram__model_8h_a438592444037281175150e3cf1543052}} 
\index{ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}!ngram\+\_\+model\+\_\+set\+\_\+iter\+\_\+model@{ngram\+\_\+model\+\_\+set\+\_\+iter\+\_\+model}}
\index{ngram\+\_\+model\+\_\+set\+\_\+iter\+\_\+model@{ngram\+\_\+model\+\_\+set\+\_\+iter\+\_\+model}!ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}}
\subsubsection{ngram\+\_\+model\+\_\+set\+\_\+iter\+\_\+model()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT \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 397 of file ngram\+\_\+model\+\_\+set.\+c.



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

\mbox{\label{ngram__model_8h_a038a174f17632703cffce02611149265}} 
\index{ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}!ngram\+\_\+model\+\_\+set\+\_\+iter\+\_\+next@{ngram\+\_\+model\+\_\+set\+\_\+iter\+\_\+next}}
\index{ngram\+\_\+model\+\_\+set\+\_\+iter\+\_\+next@{ngram\+\_\+model\+\_\+set\+\_\+iter\+\_\+next}!ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}}
\subsubsection{ngram\+\_\+model\+\_\+set\+\_\+iter\+\_\+next()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT \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 N\+U\+LL if no models remain. 
\end{DoxyReturn}


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



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

\mbox{\label{ngram__model_8h_ad87975912cfe1ac5d0c3ebe12de79209}} 
\index{ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}!ngram\+\_\+model\+\_\+set\+\_\+known\+\_\+wid@{ngram\+\_\+model\+\_\+set\+\_\+known\+\_\+wid}}
\index{ngram\+\_\+model\+\_\+set\+\_\+known\+\_\+wid@{ngram\+\_\+model\+\_\+set\+\_\+known\+\_\+wid}!ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}}
\subsubsection{ngram\+\_\+model\+\_\+set\+\_\+known\+\_\+wid()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT 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 468 of file ngram\+\_\+model\+\_\+set.\+c.



References ngram\+\_\+model\+\_\+s\+::n\+\_\+words.

\mbox{\label{ngram__model_8h_a1797a53b95a2a1ca2a6be732918d9fa0}} 
\index{ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}!ngram\+\_\+model\+\_\+set\+\_\+lookup@{ngram\+\_\+model\+\_\+set\+\_\+lookup}}
\index{ngram\+\_\+model\+\_\+set\+\_\+lookup@{ngram\+\_\+model\+\_\+set\+\_\+lookup}!ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}}
\subsubsection{ngram\+\_\+model\+\_\+set\+\_\+lookup()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT \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 N\+U\+LL if no language model by that name exists. 
\end{DoxyReturn}


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

\mbox{\label{ngram__model_8h_afb7b13dbb4a3149b2fa9f7b15dbe35e8}} 
\index{ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}!ngram\+\_\+model\+\_\+set\+\_\+read@{ngram\+\_\+model\+\_\+set\+\_\+read}}
\index{ngram\+\_\+model\+\_\+set\+\_\+read@{ngram\+\_\+model\+\_\+set\+\_\+read}!ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}}
\subsubsection{ngram\+\_\+model\+\_\+set\+\_\+read()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT \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 \char`\"{}control file\char`\"{} of the type used in Sphinx-\/\+II and Sphinx-\/\+I\+II. 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\+L\+M\+Filen\+Name and L\+M\+Name pairs. The new format allows a set of L\+M\+Class files to be read in and referred to by the trigram L\+Ms.

No \char`\"{}comments\char`\"{} 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_a1c1b2ba3b137a39e9e835a8f3e27d381}. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
newly created language model set. 
\end{DoxyReturn}


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

\mbox{\label{ngram__model_8h_af761011a07b87c209e6d174e07b34617}} 
\index{ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}!ngram\+\_\+model\+\_\+set\+\_\+remove@{ngram\+\_\+model\+\_\+set\+\_\+remove}}
\index{ngram\+\_\+model\+\_\+set\+\_\+remove@{ngram\+\_\+model\+\_\+set\+\_\+remove}!ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}}
\subsubsection{ngram\+\_\+model\+\_\+set\+\_\+remove()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT \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 580 of file ngram\+\_\+model\+\_\+set.\+c.

\mbox{\label{ngram__model_8h_a5e7a3fd20d32783ce07b760781f658f8}} 
\index{ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}!ngram\+\_\+model\+\_\+set\+\_\+select@{ngram\+\_\+model\+\_\+set\+\_\+select}}
\index{ngram\+\_\+model\+\_\+set\+\_\+select@{ngram\+\_\+model\+\_\+set\+\_\+select}!ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}}
\subsubsection{ngram\+\_\+model\+\_\+set\+\_\+select()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT \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 N\+U\+LL if no language model by that name exists. 
\end{DoxyReturn}


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

\mbox{\label{ngram__model_8h_ac8ff04e1bccbef23bde9e81fb61c57fe}} 
\index{ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}!ngram\+\_\+model\+\_\+write@{ngram\+\_\+model\+\_\+write}}
\index{ngram\+\_\+model\+\_\+write@{ngram\+\_\+model\+\_\+write}!ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}}
\subsubsection{ngram\+\_\+model\+\_\+write()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int ngram\+\_\+model\+\_\+write (\begin{DoxyParamCaption}\item[{\textbf{ ngram\+\_\+model\+\_\+t} $\ast$}]{model,  }\item[{const char $\ast$}]{file\+\_\+name,  }\item[{\textbf{ ngram\+\_\+file\+\_\+type\+\_\+t}}]{format }\end{DoxyParamCaption})}



Write an N-\/\+Gram model to disk. 

\begin{DoxyReturn}{Returns}
0 for success, $<$0 on error 
\end{DoxyReturn}


Definition at line 167 of file ngram\+\_\+model.\+c.



References E\+\_\+\+E\+R\+R\+OR, ngram\+\_\+model\+\_\+s\+::funcs, ngram\+\_\+model\+\_\+s\+::n, ngram\+\_\+model\+\_\+s\+::n\+\_\+counts, N\+G\+R\+A\+M\+\_\+\+A\+R\+PA, N\+G\+R\+A\+M\+\_\+\+A\+U\+TO, N\+G\+R\+A\+M\+\_\+\+D\+MP, ngram\+\_\+file\+\_\+name\+\_\+to\+\_\+type(), N\+G\+R\+A\+M\+\_\+\+I\+N\+V\+A\+L\+ID, and ngram\+\_\+model\+\_\+s\+::refcount.

\mbox{\label{ngram__model_8h_a218d8d140b93d3d8008f8933f9e04ec6}} 
\index{ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}!ngram\+\_\+ng\+\_\+prob@{ngram\+\_\+ng\+\_\+prob}}
\index{ngram\+\_\+ng\+\_\+prob@{ngram\+\_\+ng\+\_\+prob}!ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}}
\subsubsection{ngram\+\_\+ng\+\_\+prob()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 ngram\+\_\+ng\+\_\+prob (\begin{DoxyParamCaption}\item[{\textbf{ ngram\+\_\+model\+\_\+t} $\ast$}]{model,  }\item[{int32}]{wid,  }\item[{int32 $\ast$}]{history,  }\item[{int32}]{n\+\_\+hist,  }\item[{int32 $\ast$}]{n\+\_\+used }\end{DoxyParamCaption})}



Quick \char`\"{}raw\char`\"{} probability lookup for a general N-\/\+Gram. 

See documentation for \doxyref{ngram\+\_\+ng\+\_\+score()}{p.}{ngram__model_8h_a6ac5799e78ea4ad82a11e2439016471e} and ngram\+\_\+apply\+\_\+weights() for an explanation of this. 

Definition at line 570 of file ngram\+\_\+model.\+c.



References ngram\+\_\+model\+\_\+s\+::classes, ngram\+\_\+model\+\_\+s\+::funcs, ngram\+\_\+model\+\_\+s\+::log\+\_\+zero, N\+G\+R\+A\+M\+\_\+\+I\+N\+V\+A\+L\+I\+D\+\_\+\+W\+ID, ngram\+\_\+funcs\+\_\+s\+::raw\+\_\+score, and ngram\+\_\+class\+\_\+s\+::tag\+\_\+wid.

\mbox{\label{ngram__model_8h_a68cfda3f503e1a4a87f08aa5a3a5ea88}} 
\index{ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}!ngram\+\_\+prob@{ngram\+\_\+prob}}
\index{ngram\+\_\+prob@{ngram\+\_\+prob}!ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}}
\subsubsection{ngram\+\_\+prob()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 ngram\+\_\+prob (\begin{DoxyParamCaption}\item[{\textbf{ ngram\+\_\+model\+\_\+t} $\ast$}]{model,  }\item[{const char $\ast$}]{word,  }\item[{}]{... }\end{DoxyParamCaption})}



Get the \char`\"{}raw\char`\"{} log-\/probability for a general N-\/\+Gram. 

This returns the log-\/probability of an N-\/\+Gram, as defined in the language model file, before any language weighting, interpolation, or insertion penalty has been applied.

\begin{DoxyNote}{Note}
When backing off to a unigram from a bigram or trigram, the unigram weight (interpolation with uniform) is not removed. 
\end{DoxyNote}


Definition at line 600 of file ngram\+\_\+model.\+c.

\mbox{\label{ngram__model_8h_a9c23d79885af400e17ac2a1b7169660d}} 
\index{ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}!ngram\+\_\+score@{ngram\+\_\+score}}
\index{ngram\+\_\+score@{ngram\+\_\+score}!ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}}
\subsubsection{ngram\+\_\+score()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 ngram\+\_\+score (\begin{DoxyParamCaption}\item[{\textbf{ ngram\+\_\+model\+\_\+t} $\ast$}]{model,  }\item[{const char $\ast$}]{word,  }\item[{}]{... }\end{DoxyParamCaption})}



Get the score (scaled, interpolated log-\/probability) for a general N-\/\+Gram. 

The argument list consists of the history words (as null-\/terminated strings) of the N-\/\+Gram, {\bfseries in reverse order}, followed by N\+U\+LL. Therefore, if you wanted to get the N-\/\+Gram score for \char`\"{}a whole joy\char`\"{}, you would call\+:


\begin{DoxyPre}
 score = ngram\_score(model, "joy", "whole", "a", NULL);
\end{DoxyPre}


This is not the function to use in decoding, because it has some overhead for looking up words. Use \doxyref{ngram\+\_\+ng\+\_\+score()}{p.}{ngram__model_8h_a6ac5799e78ea4ad82a11e2439016471e}, \doxyref{ngram\+\_\+tg\+\_\+score()}{p.}{ngram__model_8h_a0f8ad53c1a7cab528113b74aad00f15a}, or \doxyref{ngram\+\_\+bg\+\_\+score()}{p.}{ngram__model_8h_a8c06698fbcb0ef82420088ace045ae81} instead. In the future there will probably be a version that takes a general language model state object, to support suffix-\/array LM and things like that.

If one of the words is not in the LM\textquotesingle{}s vocabulary, the result will depend on whether this is an open or closed vocabulary language model. For an open-\/vocabulary model, unknown words are all mapped to the unigram $<$U\+NK$>$ which has a non-\/zero probability and also participates in higher-\/order N-\/\+Grams. Therefore, you will get a score of some sort in this case.

For a closed-\/vocabulary model, unknown words are impossible and thus have zero probability. Therefore, if {\ttfamily word} is unknown, this function will return a \char`\"{}zero\char`\"{} log-\/probability, i.\+e. a large negative number. To obtain this number for comparison, call \doxyref{ngram\+\_\+zero()}{p.}{ngram__model_8h_ae401a87ad55ae64f286dcd83170f7100}. 

Definition at line 524 of file ngram\+\_\+model.\+c.

\mbox{\label{ngram__model_8h_ae0cf3a94128927e2be6422d2de34f49b}} 
\index{ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}!ngram\+\_\+score\+\_\+to\+\_\+prob@{ngram\+\_\+score\+\_\+to\+\_\+prob}}
\index{ngram\+\_\+score\+\_\+to\+\_\+prob@{ngram\+\_\+score\+\_\+to\+\_\+prob}!ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}}
\subsubsection{ngram\+\_\+score\+\_\+to\+\_\+prob()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 ngram\+\_\+score\+\_\+to\+\_\+prob (\begin{DoxyParamCaption}\item[{\textbf{ ngram\+\_\+model\+\_\+t} $\ast$}]{model,  }\item[{int32}]{score }\end{DoxyParamCaption})}



Convert score to \char`\"{}raw\char`\"{} log-\/probability. 

\begin{DoxyNote}{Note}
The unigram weight (interpolation with uniform) is not removed, since there is no way to know which order of N-\/\+Gram generated {\ttfamily score}.
\end{DoxyNote}

\begin{DoxyParams}{Parameters}
{\em model} & The N-\/\+Gram model from which score was obtained. \\
\hline
{\em score} & The N-\/\+Gram score to convert \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The raw log-\/probability value. 
\end{DoxyReturn}


Definition at line 631 of file ngram\+\_\+model.\+c.



References ngram\+\_\+model\+\_\+s\+::log\+\_\+wip.

\mbox{\label{ngram__model_8h_affb3d938049e58c191e72858a7191e9c}} 
\index{ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}!ngram\+\_\+str\+\_\+to\+\_\+type@{ngram\+\_\+str\+\_\+to\+\_\+type}}
\index{ngram\+\_\+str\+\_\+to\+\_\+type@{ngram\+\_\+str\+\_\+to\+\_\+type}!ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}}
\subsubsection{ngram\+\_\+str\+\_\+to\+\_\+type()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT \textbf{ ngram\+\_\+file\+\_\+type\+\_\+t} ngram\+\_\+str\+\_\+to\+\_\+type (\begin{DoxyParamCaption}\item[{const char $\ast$}]{str\+\_\+name }\end{DoxyParamCaption})}



Get the N-\/\+Gram file type from a string. 

\begin{DoxyReturn}{Returns}
file type, or N\+G\+R\+A\+M\+\_\+\+I\+N\+V\+A\+L\+ID if no such file type exists. 
\end{DoxyReturn}


Definition at line 97 of file ngram\+\_\+model.\+c.



References N\+G\+R\+A\+M\+\_\+\+A\+R\+PA, N\+G\+R\+A\+M\+\_\+\+D\+MP, N\+G\+R\+A\+M\+\_\+\+I\+N\+V\+A\+L\+ID, and strcmp\+\_\+nocase().

\mbox{\label{ngram__model_8h_a992b8a8d7f623e2662ae94991f6aec55}} 
\index{ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}!ngram\+\_\+type\+\_\+to\+\_\+str@{ngram\+\_\+type\+\_\+to\+\_\+str}}
\index{ngram\+\_\+type\+\_\+to\+\_\+str@{ngram\+\_\+type\+\_\+to\+\_\+str}!ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}}
\subsubsection{ngram\+\_\+type\+\_\+to\+\_\+str()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT char const$\ast$ ngram\+\_\+type\+\_\+to\+\_\+str (\begin{DoxyParamCaption}\item[{int}]{type }\end{DoxyParamCaption})}



Get the canonical name for an N-\/\+Gram file type. 

\begin{DoxyReturn}{Returns}
read-\/only string with the name for this file type, or N\+U\+LL if no such type exists. 
\end{DoxyReturn}


Definition at line 107 of file ngram\+\_\+model.\+c.



References N\+G\+R\+A\+M\+\_\+\+A\+R\+PA, and N\+G\+R\+A\+M\+\_\+\+D\+MP.

\mbox{\label{ngram__model_8h_a1469e9e1c8516a77c9ac1e248a61ef4e}} 
\index{ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}!ngram\+\_\+unknown\+\_\+wid@{ngram\+\_\+unknown\+\_\+wid}}
\index{ngram\+\_\+unknown\+\_\+wid@{ngram\+\_\+unknown\+\_\+wid}!ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}}
\subsubsection{ngram\+\_\+unknown\+\_\+wid()}
{\footnotesize\ttfamily S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+RT int32 ngram\+\_\+unknown\+\_\+wid (\begin{DoxyParamCaption}\item[{\textbf{ ngram\+\_\+model\+\_\+t} $\ast$}]{model }\end{DoxyParamCaption})}



Get the unknown word ID for a language model. 

Language models can be either \char`\"{}open vocabulary\char`\"{} or \char`\"{}closed
vocabulary\char`\"{}. The difference is that the former assigns a fixed non-\/zero unigram probability to unknown words, while the latter does not allow unknown words (or, equivalently, it assigns them zero probability). If this is a closed vocabulary model, this function will return N\+G\+R\+A\+M\+\_\+\+I\+N\+V\+A\+L\+I\+D\+\_\+\+W\+ID.

\begin{DoxyReturn}{Returns}
The ID for the unknown word, or N\+G\+R\+A\+M\+\_\+\+I\+N\+V\+A\+L\+I\+D\+\_\+\+W\+ID if none exists. 
\end{DoxyReturn}


Definition at line 644 of file ngram\+\_\+model.\+c.



References hash\+\_\+table\+\_\+lookup\+\_\+int32(), N\+G\+R\+A\+M\+\_\+\+I\+N\+V\+A\+L\+I\+D\+\_\+\+W\+ID, and ngram\+\_\+model\+\_\+s\+::wid.



Referenced by ngram\+\_\+wid().

