\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$>$}\\*
{\ttfamily \#include $<$sphinxbase/sphinxbase\+\_\+export.\+h$>$}\\*
{\ttfamily \#include $<$sphinxbase/prim\+\_\+type.\+h$>$}\\*
{\ttfamily \#include $<$sphinxbase/cmd\+\_\+ln.\+h$>$}\\*
{\ttfamily \#include $<$sphinxbase/logmath.\+h$>$}\\*
{\ttfamily \#include $<$sphinxbase/mmio.\+h$>$}\\*
\subsection*{Macros}
\begin{DoxyCompactItemize}
\item 
\#define {\bf N\+G\+R\+A\+M\+\_\+\+I\+N\+V\+A\+L\+I\+D\+\_\+\+W\+I\+D}~-\/1\label{ngram__model_8h_a3d4b3dddd0ff67e13d30c9bf053d01ab}

\begin{DoxyCompactList}\small\item\em Impossible word I\+D. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Typedefs}
\begin{DoxyCompactItemize}
\item 
typedef struct {\bf ngram\+\_\+model\+\_\+s} {\bf ngram\+\_\+model\+\_\+t}\label{ngram__model_8h_afaaf0c00e20056d97efcd97e4cae4ea7}

\begin{DoxyCompactList}\small\item\em Abstract type representing an N-\/\+Gram based language model. \end{DoxyCompactList}\item 
typedef struct {\bf ngram\+\_\+class\+\_\+s} {\bf ngram\+\_\+class\+\_\+t}\label{ngram__model_8h_ae36b2f037b2ea751dff23f082379c264}

\begin{DoxyCompactList}\small\item\em Abstract type representing a word class in an N-\/\+Gram model. \end{DoxyCompactList}\item 
typedef enum {\bf ngram\+\_\+file\+\_\+type\+\_\+e} {\bf ngram\+\_\+file\+\_\+type\+\_\+t}\label{ngram__model_8h_a0e7d02703c48237b2afea436392dcb82}

\begin{DoxyCompactList}\small\item\em File types for N-\/\+Gram files. \end{DoxyCompactList}\item 
typedef enum {\bf ngram\+\_\+case\+\_\+e} {\bf ngram\+\_\+case\+\_\+t}\label{ngram__model_8h_ab9b3023d92b99927d1e851108ac3bdad}

\begin{DoxyCompactList}\small\item\em Constants for case folding. \end{DoxyCompactList}\item 
typedef struct {\bf ngram\+\_\+iter\+\_\+s} {\bf ngram\+\_\+iter\+\_\+t}\label{ngram__model_8h_ac7de090a02fa12a8bba84abb4d5236aa}

\begin{DoxyCompactList}\small\item\em M-\/gram iterator object. \end{DoxyCompactList}\item 
typedef struct \\*
{\bf ngram\+\_\+model\+\_\+set\+\_\+iter\+\_\+s} {\bf ngram\+\_\+model\+\_\+set\+\_\+iter\+\_\+t}\label{ngram__model_8h_afffd75c5bde8dd84107449468be48547}

\begin{DoxyCompactList}\small\item\em Iterator over language models in a set. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Enumerations}
\begin{DoxyCompactItemize}
\item 
enum {\bf ngram\+\_\+file\+\_\+type\+\_\+e} \{ \\*
{\bf N\+G\+R\+A\+M\+\_\+\+I\+N\+V\+A\+L\+I\+D} = -\/1, 
{\bf N\+G\+R\+A\+M\+\_\+\+A\+U\+T\+O}, 
{\bf N\+G\+R\+A\+M\+\_\+\+A\+R\+P\+A}, 
{\bf N\+G\+R\+A\+M\+\_\+\+D\+M\+P}, 
\\*
{\bf N\+G\+R\+A\+M\+\_\+\+D\+M\+P32}
 \}
\begin{DoxyCompactList}\small\item\em File types for N-\/\+Gram files. \end{DoxyCompactList}\item 
enum {\bf ngram\+\_\+case\+\_\+e} \{ {\bfseries N\+G\+R\+A\+M\+\_\+\+U\+P\+P\+E\+R}, 
{\bfseries N\+G\+R\+A\+M\+\_\+\+L\+O\+W\+E\+R}
 \}\label{ngram__model_8h_aad16a0a1edf29ba8c0df43959c0c4771}

\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\+R\+T {\bf ngram\+\_\+model\+\_\+t} $\ast$ {\bf ngram\+\_\+model\+\_\+read} ({\bf cmd\+\_\+ln\+\_\+t} $\ast$config, const char $\ast$file\+\_\+name, {\bf ngram\+\_\+file\+\_\+type\+\_\+t} file\+\_\+type, {\bf 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\+R\+T int {\bf ngram\+\_\+model\+\_\+write} ({\bf ngram\+\_\+model\+\_\+t} $\ast$model, const char $\ast$file\+\_\+name, {\bf 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\+R\+T {\bf ngram\+\_\+file\+\_\+type\+\_\+t} {\bf 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\+R\+T {\bf ngram\+\_\+file\+\_\+type\+\_\+t} {\bf 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\+R\+T char const $\ast$ {\bf 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\+R\+T {\bf ngram\+\_\+model\+\_\+t} $\ast$ {\bf ngram\+\_\+model\+\_\+retain} ({\bf 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\+R\+T int {\bf ngram\+\_\+model\+\_\+free} ({\bf 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\+R\+T int {\bf ngram\+\_\+model\+\_\+recode} ({\bf 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\+R\+T int {\bf ngram\+\_\+model\+\_\+casefold} ({\bf 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\+R\+T int {\bf ngram\+\_\+model\+\_\+apply\+\_\+weights} ({\bf 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\+R\+T float32 {\bf ngram\+\_\+model\+\_\+get\+\_\+weights} ({\bf 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\+R\+T int32 {\bf ngram\+\_\+score} ({\bf 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 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T int32 {\bf ngram\+\_\+tg\+\_\+score} ({\bf ngram\+\_\+model\+\_\+t} $\ast$model, int32 w3, int32 w2, int32 w1, int32 $\ast$n\+\_\+used)\label{ngram__model_8h_a0f8ad53c1a7cab528113b74aad00f15a}

\begin{DoxyCompactList}\small\item\em Quick trigram score lookup. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T int32 {\bf ngram\+\_\+bg\+\_\+score} ({\bf ngram\+\_\+model\+\_\+t} $\ast$model, int32 w2, int32 w1, int32 $\ast$n\+\_\+used)\label{ngram__model_8h_a8c06698fbcb0ef82420088ace045ae81}

\begin{DoxyCompactList}\small\item\em Quick bigram score lookup. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T int32 {\bf ngram\+\_\+ng\+\_\+score} ({\bf ngram\+\_\+model\+\_\+t} $\ast$model, int32 wid, int32 $\ast$history, int32 n\+\_\+hist, int32 $\ast$n\+\_\+used)\label{ngram__model_8h_a6ac5799e78ea4ad82a11e2439016471e}

\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\+R\+T int32 {\bf ngram\+\_\+prob} ({\bf 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\+R\+T int32 {\bf ngram\+\_\+ng\+\_\+prob} ({\bf 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\+R\+T int32 {\bf ngram\+\_\+score\+\_\+to\+\_\+prob} ({\bf ngram\+\_\+model\+\_\+t} $\ast$model, int32 score)
\begin{DoxyCompactList}\small\item\em Convert score to \char`\"{}raw\char`\"{} log-\/probability. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T int32 {\bf ngram\+\_\+wid} ({\bf ngram\+\_\+model\+\_\+t} $\ast$model, const char $\ast$word)\label{ngram__model_8h_ad03d4355d4ea659815dc25bce8d83880}

\begin{DoxyCompactList}\small\item\em Look up numerical word I\+D. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T const char $\ast$ {\bf ngram\+\_\+word} ({\bf ngram\+\_\+model\+\_\+t} $\ast$model, int32 wid)\label{ngram__model_8h_a96e36290a005c03464ea6c637ccde2f5}

\begin{DoxyCompactList}\small\item\em Look up word string for numerical word I\+D. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T int32 {\bf ngram\+\_\+unknown\+\_\+wid} ({\bf ngram\+\_\+model\+\_\+t} $\ast$model)
\begin{DoxyCompactList}\small\item\em Get the unknown word I\+D for a language model. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T int32 {\bf ngram\+\_\+zero} ({\bf ngram\+\_\+model\+\_\+t} $\ast$model)\label{ngram__model_8h_ae401a87ad55ae64f286dcd83170f7100}

\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\+R\+T int32 {\bf ngram\+\_\+model\+\_\+get\+\_\+size} ({\bf ngram\+\_\+model\+\_\+t} $\ast$model)
\begin{DoxyCompactList}\small\item\em Get the order of the N-\/gram model (i.\+e. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T int32 const $\ast$ {\bf ngram\+\_\+model\+\_\+get\+\_\+counts} ({\bf ngram\+\_\+model\+\_\+t} $\ast$model)\label{ngram__model_8h_a187531aafc1f11214c9d061f75eae194}

\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\+R\+T {\bf ngram\+\_\+iter\+\_\+t} $\ast$ {\bf ngram\+\_\+model\+\_\+mgrams} ({\bf ngram\+\_\+model\+\_\+t} $\ast$model, int m)
\begin{DoxyCompactList}\small\item\em Iterate over all M-\/grams. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T {\bf ngram\+\_\+iter\+\_\+t} $\ast$ {\bf ngram\+\_\+iter} ({\bf ngram\+\_\+model\+\_\+t} $\ast$model, const char $\ast$word,...)\label{ngram__model_8h_ad988e0f41447ee404050caf7c7bb7b63}

\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\+R\+T {\bf ngram\+\_\+iter\+\_\+t} $\ast$ {\bf ngram\+\_\+ng\+\_\+iter} ({\bf ngram\+\_\+model\+\_\+t} $\ast$model, int32 wid, int32 $\ast$history, int32 n\+\_\+hist)\label{ngram__model_8h_a461c6e5914ce463422dfeaeee377e024}

\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\+R\+T int32 const $\ast$ {\bf ngram\+\_\+iter\+\_\+get} ({\bf 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\+R\+T {\bf ngram\+\_\+iter\+\_\+t} $\ast$ {\bf ngram\+\_\+iter\+\_\+successors} ({\bf ngram\+\_\+iter\+\_\+t} $\ast$itor)
\begin{DoxyCompactList}\small\item\em Iterate over all M-\/gram successors of an M-\/1-\/gram. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T {\bf ngram\+\_\+iter\+\_\+t} $\ast$ {\bf ngram\+\_\+iter\+\_\+next} ({\bf ngram\+\_\+iter\+\_\+t} $\ast$itor)\label{ngram__model_8h_a3a2b285c01393b3ebddaec1fefed11a4}

\begin{DoxyCompactList}\small\item\em Advance an M-\/gram iterator. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T void {\bf ngram\+\_\+iter\+\_\+free} ({\bf ngram\+\_\+iter\+\_\+t} $\ast$itor)\label{ngram__model_8h_ac9f746c8a5db78ef8b2fb7c312be4a22}

\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\+R\+T int32 {\bf ngram\+\_\+model\+\_\+add\+\_\+word} ({\bf 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\+R\+T int32 {\bf ngram\+\_\+model\+\_\+read\+\_\+classdef} ({\bf 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\+R\+T int32 {\bf ngram\+\_\+model\+\_\+add\+\_\+class} ({\bf 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\+R\+T int32 {\bf ngram\+\_\+model\+\_\+add\+\_\+class\+\_\+word} ({\bf 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\+R\+T {\bf ngram\+\_\+model\+\_\+t} $\ast$ {\bf ngram\+\_\+model\+\_\+set\+\_\+init} ({\bf cmd\+\_\+ln\+\_\+t} $\ast$config, {\bf 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\+R\+T {\bf ngram\+\_\+model\+\_\+t} $\ast$ {\bf ngram\+\_\+model\+\_\+set\+\_\+read} ({\bf cmd\+\_\+ln\+\_\+t} $\ast$config, const char $\ast$lmctlfile, {\bf logmath\+\_\+t} $\ast$lmath)
\begin{DoxyCompactList}\small\item\em Read a set of language models from a control file. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T int32 {\bf ngram\+\_\+model\+\_\+set\+\_\+count} ({\bf ngram\+\_\+model\+\_\+t} $\ast$set)\label{ngram__model_8h_a22b8f5f49231b4aef3d5a166ea7155b6}

\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\+R\+T \\*
{\bf ngram\+\_\+model\+\_\+set\+\_\+iter\+\_\+t} $\ast$ {\bf ngram\+\_\+model\+\_\+set\+\_\+iter} ({\bf 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\+R\+T \\*
{\bf ngram\+\_\+model\+\_\+set\+\_\+iter\+\_\+t} $\ast$ {\bf ngram\+\_\+model\+\_\+set\+\_\+iter\+\_\+next} ({\bf ngram\+\_\+model\+\_\+set\+\_\+iter\+\_\+t} $\ast$itor)
\begin{DoxyCompactList}\small\item\em Move to the next language model in a set. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T void {\bf ngram\+\_\+model\+\_\+set\+\_\+iter\+\_\+free} ({\bf ngram\+\_\+model\+\_\+set\+\_\+iter\+\_\+t} $\ast$itor)\label{ngram__model_8h_ae5b58f360ab6432528ffaead1d2b2a2d}

\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\+R\+T {\bf ngram\+\_\+model\+\_\+t} $\ast$ {\bf ngram\+\_\+model\+\_\+set\+\_\+iter\+\_\+model} ({\bf 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\+R\+T {\bf ngram\+\_\+model\+\_\+t} $\ast$ {\bf ngram\+\_\+model\+\_\+set\+\_\+select} ({\bf 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\+R\+T {\bf ngram\+\_\+model\+\_\+t} $\ast$ {\bf ngram\+\_\+model\+\_\+set\+\_\+lookup} ({\bf 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 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T const char $\ast$ {\bf ngram\+\_\+model\+\_\+set\+\_\+current} ({\bf ngram\+\_\+model\+\_\+t} $\ast$set)\label{ngram__model_8h_a95a4da1562cb6d67a01a733bd0bbb436}

\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\+R\+T {\bf ngram\+\_\+model\+\_\+t} $\ast$ {\bf ngram\+\_\+model\+\_\+set\+\_\+interp} ({\bf 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\+R\+T {\bf ngram\+\_\+model\+\_\+t} $\ast$ {\bf ngram\+\_\+model\+\_\+set\+\_\+add} ({\bf ngram\+\_\+model\+\_\+t} $\ast$set, {\bf 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\+R\+T {\bf ngram\+\_\+model\+\_\+t} $\ast$ {\bf ngram\+\_\+model\+\_\+set\+\_\+remove} ({\bf 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 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T void {\bf ngram\+\_\+model\+\_\+set\+\_\+map\+\_\+words} ({\bf ngram\+\_\+model\+\_\+t} $\ast$set, const char $\ast$$\ast$words, int32 n\+\_\+words)\label{ngram__model_8h_a3e8abe87ae12cfbe1b79fd99213abe2d}

\begin{DoxyCompactList}\small\item\em Set the word-\/to-\/\+I\+D mapping for this model set. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T int32 {\bf ngram\+\_\+model\+\_\+set\+\_\+current\+\_\+wid} ({\bf ngram\+\_\+model\+\_\+t} $\ast$set, int32 set\+\_\+wid)
\begin{DoxyCompactList}\small\item\em Query the word-\/\+I\+D mapping for the current language model. \end{DoxyCompactList}\item 
S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T int32 {\bf ngram\+\_\+model\+\_\+set\+\_\+known\+\_\+wid} ({\bf ngram\+\_\+model\+\_\+t} $\ast$set, int32 set\+\_\+wid)
\begin{DoxyCompactList}\small\item\em Test whether a word I\+D 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\+R\+T void {\bf ngram\+\_\+model\+\_\+flush} ({\bf 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}


Definition in file {\bf ngram\+\_\+model.\+h}.



\subsection{Enumeration Type Documentation}
\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}]{\setlength{\rightskip}{0pt plus 5cm}enum {\bf ngram\+\_\+file\+\_\+type\+\_\+e}}\label{ngram__model_8h_a406c0d64c15a9d1749d07c8ab6e0ae74}


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

\begin{Desc}
\item[Enumerator]\par
\begin{description}
\index{N\+G\+R\+A\+M\+\_\+\+I\+N\+V\+A\+L\+I\+D@{N\+G\+R\+A\+M\+\_\+\+I\+N\+V\+A\+L\+I\+D}!ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}}\index{ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}!N\+G\+R\+A\+M\+\_\+\+I\+N\+V\+A\+L\+I\+D@{N\+G\+R\+A\+M\+\_\+\+I\+N\+V\+A\+L\+I\+D}}\item[{\em 
N\+G\+R\+A\+M\+\_\+\+I\+N\+V\+A\+L\+I\+D\label{ngram__model_8h_a406c0d64c15a9d1749d07c8ab6e0ae74a2cf596c8b0c63a3a0ba1fe33326cc796}
}]Not a valid file type. \index{N\+G\+R\+A\+M\+\_\+\+A\+U\+T\+O@{N\+G\+R\+A\+M\+\_\+\+A\+U\+T\+O}!ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}}\index{ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}!N\+G\+R\+A\+M\+\_\+\+A\+U\+T\+O@{N\+G\+R\+A\+M\+\_\+\+A\+U\+T\+O}}\item[{\em 
N\+G\+R\+A\+M\+\_\+\+A\+U\+T\+O\label{ngram__model_8h_a406c0d64c15a9d1749d07c8ab6e0ae74a441701bf8ae0a2b79716feb31b5f257a}
}]Determine file type automatically. \index{N\+G\+R\+A\+M\+\_\+\+A\+R\+P\+A@{N\+G\+R\+A\+M\+\_\+\+A\+R\+P\+A}!ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}}\index{ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}!N\+G\+R\+A\+M\+\_\+\+A\+R\+P\+A@{N\+G\+R\+A\+M\+\_\+\+A\+R\+P\+A}}\item[{\em 
N\+G\+R\+A\+M\+\_\+\+A\+R\+P\+A\label{ngram__model_8h_a406c0d64c15a9d1749d07c8ab6e0ae74a77ef2341d826b3cc8b836e3af1efba99}
}]A\+R\+P\+A\+B\+O text format (the standard). \index{N\+G\+R\+A\+M\+\_\+\+D\+M\+P@{N\+G\+R\+A\+M\+\_\+\+D\+M\+P}!ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}}\index{ngram\+\_\+model.\+h@{ngram\+\_\+model.\+h}!N\+G\+R\+A\+M\+\_\+\+D\+M\+P@{N\+G\+R\+A\+M\+\_\+\+D\+M\+P}}\item[{\em 
N\+G\+R\+A\+M\+\_\+\+D\+M\+P\label{ngram__model_8h_a406c0d64c15a9d1749d07c8ab6e0ae74addfc3620d0fbc6f05f7f8e455245dd92}
}]Sphinx .D\+M\+P format. \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}}\item[{\em 
N\+G\+R\+A\+M\+\_\+\+D\+M\+P32\label{ngram__model_8h_a406c0d64c15a9d1749d07c8ab6e0ae74ab8fe83d2dec88c1c8cb4d82a8a528bb8}
}]Sphinx .D\+M\+P32 format (N\+O\+T S\+U\+P\+P\+O\+R\+T\+E\+D) \end{description}
\end{Desc}


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



\subsection{Function Documentation}
\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}]{\setlength{\rightskip}{0pt plus 5cm}S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T {\bf ngram\+\_\+file\+\_\+type\+\_\+t} ngram\+\_\+file\+\_\+name\+\_\+to\+\_\+type (
\begin{DoxyParamCaption}
\item[{const char $\ast$}]{file\+\_\+name}
\end{DoxyParamCaption}
)}\label{ngram__model_8h_ad758d3f491d501bdec2ada8088e9b656}


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\+I\+D if none could be guessed. 
\end{DoxyReturn}


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



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



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

\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}]{\setlength{\rightskip}{0pt plus 5cm}S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T int32 const$\ast$ ngram\+\_\+iter\+\_\+get (
\begin{DoxyParamCaption}
\item[{{\bf ngram\+\_\+iter\+\_\+t} $\ast$}]{itor, }
\item[{int32 $\ast$}]{out\+\_\+score, }
\item[{int32 $\ast$}]{out\+\_\+bowt}
\end{DoxyParamCaption}
)}\label{ngram__model_8h_a240c738781daa226a2fc13395dbdb514}


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.

\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}]{\setlength{\rightskip}{0pt plus 5cm}S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T {\bf ngram\+\_\+iter\+\_\+t}$\ast$ ngram\+\_\+iter\+\_\+successors (
\begin{DoxyParamCaption}
\item[{{\bf ngram\+\_\+iter\+\_\+t} $\ast$}]{itor}
\end{DoxyParamCaption}
)}\label{ngram__model_8h_ae85f41e2defc5b65b12026d29cd4fdaa}


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\+\_\+model\+\_\+s\+::funcs, ngram\+\_\+iter\+\_\+s\+::m, ngram\+\_\+model\+\_\+s\+::n, and ngram\+\_\+funcs\+\_\+s\+::successors.

\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}]{\setlength{\rightskip}{0pt plus 5cm}S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T int32 ngram\+\_\+model\+\_\+add\+\_\+class (
\begin{DoxyParamCaption}
\item[{{\bf 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}
)}\label{ngram__model_8h_a0481b03a2bf03ef0a197da0a1f7d1caa}


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.



References ckd\+\_\+calloc, ckd\+\_\+realloc, ngram\+\_\+model\+\_\+s\+::classes, E\+\_\+\+E\+R\+R\+O\+R, glist\+\_\+add\+\_\+float32(), glist\+\_\+free(), glist\+\_\+reverse(), ngram\+\_\+model\+\_\+s\+::n\+\_\+classes, N\+G\+R\+A\+M\+\_\+\+I\+N\+V\+A\+L\+I\+D\+\_\+\+W\+I\+D, ngram\+\_\+model\+\_\+add\+\_\+word(), ngram\+\_\+unknown\+\_\+wid(), and ngram\+\_\+wid().



Referenced by ngram\+\_\+model\+\_\+read\+\_\+classdef(), and ngram\+\_\+model\+\_\+set\+\_\+read().

\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}]{\setlength{\rightskip}{0pt plus 5cm}S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T int32 ngram\+\_\+model\+\_\+add\+\_\+class\+\_\+word (
\begin{DoxyParamCaption}
\item[{{\bf ngram\+\_\+model\+\_\+t} $\ast$}]{model, }
\item[{const char $\ast$}]{classname, }
\item[{const char $\ast$}]{word, }
\item[{float32}]{weight}
\end{DoxyParamCaption}
)}\label{ngram__model_8h_a39eabb4994cf99c4bc2116e12af0c9f1}


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 I\+D for the new word. 
\end{DoxyReturn}


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



References ngram\+\_\+model\+\_\+s\+::classes, E\+\_\+\+E\+R\+R\+O\+R, 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\+I\+D, 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.

\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}]{\setlength{\rightskip}{0pt plus 5cm}S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T int32 ngram\+\_\+model\+\_\+add\+\_\+word (
\begin{DoxyParamCaption}
\item[{{\bf ngram\+\_\+model\+\_\+t} $\ast$}]{model, }
\item[{const char $\ast$}]{word, }
\item[{float32}]{weight}
\end{DoxyParamCaption}
)}\label{ngram__model_8h_a38e034d58ee0d6a4c0dd6f852cb71c3c}


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 I\+D for the new word. 
\end{DoxyReturn}


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



References ngram\+\_\+funcs\+\_\+s\+::add\+\_\+ug, E\+\_\+\+W\+A\+R\+N, ngram\+\_\+model\+\_\+s\+::funcs, ngram\+\_\+model\+\_\+s\+::lmath, ngram\+\_\+model\+\_\+s\+::log\+\_\+zero, logmath\+\_\+log(), N\+G\+R\+A\+M\+\_\+\+I\+N\+V\+A\+L\+I\+D\+\_\+\+W\+I\+D, and ngram\+\_\+model\+\_\+s\+::writable.



Referenced by ngram\+\_\+model\+\_\+add\+\_\+class().

\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}]{\setlength{\rightskip}{0pt plus 5cm}S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T int ngram\+\_\+model\+\_\+apply\+\_\+weights (
\begin{DoxyParamCaption}
\item[{{\bf ngram\+\_\+model\+\_\+t} $\ast$}]{model, }
\item[{float32}]{lw, }
\item[{float32}]{wip, }
\item[{float32}]{uw}
\end{DoxyParamCaption}
)}\label{ngram__model_8h_aa4b8d7c1f3d873b8458c0cfee13af4da}


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.



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

\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}]{\setlength{\rightskip}{0pt plus 5cm}S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T int ngram\+\_\+model\+\_\+casefold (
\begin{DoxyParamCaption}
\item[{{\bf ngram\+\_\+model\+\_\+t} $\ast$}]{model, }
\item[{int}]{kase}
\end{DoxyParamCaption}
)}\label{ngram__model_8h_a41b938a2c4b129dc0df37b2312d65506}


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

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

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



References ckd\+\_\+salloc, E\+\_\+\+W\+A\+R\+N, hash\+\_\+table\+\_\+enter\+\_\+int32, hash\+\_\+table\+\_\+free(), hash\+\_\+table\+\_\+new(), lcase(), ngram\+\_\+model\+\_\+s\+::n\+\_\+words, ucase(), ngram\+\_\+model\+\_\+s\+::wid, ngram\+\_\+model\+\_\+s\+::word\+\_\+str, and ngram\+\_\+model\+\_\+s\+::writable.

\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}]{\setlength{\rightskip}{0pt plus 5cm}S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T void ngram\+\_\+model\+\_\+flush (
\begin{DoxyParamCaption}
\item[{{\bf ngram\+\_\+model\+\_\+t} $\ast$}]{lm}
\end{DoxyParamCaption}
)}\label{ngram__model_8h_a8304f56d82278824b0a94c254d7235aa}


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.

\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}]{\setlength{\rightskip}{0pt plus 5cm}S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T int ngram\+\_\+model\+\_\+free (
\begin{DoxyParamCaption}
\item[{{\bf ngram\+\_\+model\+\_\+t} $\ast$}]{model}
\end{DoxyParamCaption}
)}\label{ngram__model_8h_aec73d28e7285e539a0b44a7ac0cbe489}


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.



References ckd\+\_\+free(), ngram\+\_\+model\+\_\+s\+::classes, ngram\+\_\+funcs\+\_\+s\+::free, ngram\+\_\+model\+\_\+s\+::funcs, hash\+\_\+table\+\_\+free(), ngram\+\_\+model\+\_\+s\+::n\+\_\+classes, ngram\+\_\+model\+\_\+s\+::n\+\_\+counts, ngram\+\_\+class\+\_\+s\+::n\+\_\+hash, ngram\+\_\+model\+\_\+s\+::n\+\_\+words, ngram\+\_\+class\+\_\+s\+::n\+\_\+words, ngram\+\_\+model\+\_\+s\+::refcount, ngram\+\_\+class\+\_\+s\+::start\+\_\+wid, ngram\+\_\+model\+\_\+s\+::wid, ngram\+\_\+class\+\_\+s\+::ngram\+\_\+hash\+\_\+s\+::wid, ngram\+\_\+model\+\_\+s\+::word\+\_\+str, and ngram\+\_\+model\+\_\+s\+::writable.



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

\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}]{\setlength{\rightskip}{0pt plus 5cm}S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T int32 ngram\+\_\+model\+\_\+get\+\_\+size (
\begin{DoxyParamCaption}
\item[{{\bf ngram\+\_\+model\+\_\+t} $\ast$}]{model}
\end{DoxyParamCaption}
)}\label{ngram__model_8h_a462d374099a4fe8b3c3195b5e2013545}


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.



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

\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}]{\setlength{\rightskip}{0pt plus 5cm}S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T float32 ngram\+\_\+model\+\_\+get\+\_\+weights (
\begin{DoxyParamCaption}
\item[{{\bf ngram\+\_\+model\+\_\+t} $\ast$}]{model, }
\item[{int32 $\ast$}]{out\+\_\+log\+\_\+wip, }
\item[{int32 $\ast$}]{out\+\_\+log\+\_\+uw}
\end{DoxyParamCaption}
)}\label{ngram__model_8h_a30170c1307e065e1f7159a04f75df304}


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.

\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}]{\setlength{\rightskip}{0pt plus 5cm}S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T {\bf ngram\+\_\+iter\+\_\+t}$\ast$ ngram\+\_\+model\+\_\+mgrams (
\begin{DoxyParamCaption}
\item[{{\bf ngram\+\_\+model\+\_\+t} $\ast$}]{model, }
\item[{int}]{m}
\end{DoxyParamCaption}
)}\label{ngram__model_8h_a12683dda2253dc45680102f02fbdb1e2}


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\+L\+L if no N-\/grams of order M+1 exist. 
\end{DoxyReturn}


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



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

\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}]{\setlength{\rightskip}{0pt plus 5cm}S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T {\bf ngram\+\_\+model\+\_\+t}$\ast$ ngram\+\_\+model\+\_\+read (
\begin{DoxyParamCaption}
\item[{{\bf cmd\+\_\+ln\+\_\+t} $\ast$}]{config, }
\item[{const char $\ast$}]{file\+\_\+name, }
\item[{{\bf ngram\+\_\+file\+\_\+type\+\_\+t}}]{file\+\_\+type, }
\item[{{\bf logmath\+\_\+t} $\ast$}]{lmath}
\end{DoxyParamCaption}
)}\label{ngram__model_8h_ab0c840f2bdfc38cea08bb70054f76624}


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\+T\+O 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.



References cmd\+\_\+ln\+\_\+exists\+\_\+r(), E\+\_\+\+E\+R\+R\+O\+R, N\+G\+R\+A\+M\+\_\+\+A\+R\+P\+A, N\+G\+R\+A\+M\+\_\+\+A\+U\+T\+O, N\+G\+R\+A\+M\+\_\+\+D\+M\+P, and ngram\+\_\+model\+\_\+apply\+\_\+weights().



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

\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}]{\setlength{\rightskip}{0pt plus 5cm}S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T int32 ngram\+\_\+model\+\_\+read\+\_\+classdef (
\begin{DoxyParamCaption}
\item[{{\bf ngram\+\_\+model\+\_\+t} $\ast$}]{model, }
\item[{const char $\ast$}]{file\+\_\+name}
\end{DoxyParamCaption}
)}\label{ngram__model_8h_a9b2a86c23543158754373c5456fe890d}


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.



References ckd\+\_\+free(), glist\+\_\+free(), gnode\+\_\+ptr, hash\+\_\+table\+\_\+free(), hash\+\_\+table\+\_\+new(), hash\+\_\+table\+\_\+tolist(), ngram\+\_\+model\+\_\+add\+\_\+class(), and hash\+\_\+entry\+\_\+s\+::val.

\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}]{\setlength{\rightskip}{0pt plus 5cm}S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T int ngram\+\_\+model\+\_\+recode (
\begin{DoxyParamCaption}
\item[{{\bf ngram\+\_\+model\+\_\+t} $\ast$}]{model, }
\item[{const char $\ast$}]{from, }
\item[{const char $\ast$}]{to}
\end{DoxyParamCaption}
)}\label{ngram__model_8h_aac2b3fd054597c2fdfbb59db97d72ec0}


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'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's a bug! 

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

\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}]{\setlength{\rightskip}{0pt plus 5cm}S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T {\bf ngram\+\_\+model\+\_\+t}$\ast$ ngram\+\_\+model\+\_\+retain (
\begin{DoxyParamCaption}
\item[{{\bf ngram\+\_\+model\+\_\+t} $\ast$}]{model}
\end{DoxyParamCaption}
)}\label{ngram__model_8h_a046e6ff8cd8787e412400534a9649a81}


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.

\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}]{\setlength{\rightskip}{0pt plus 5cm}S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T {\bf ngram\+\_\+model\+\_\+t}$\ast$ ngram\+\_\+model\+\_\+set\+\_\+add (
\begin{DoxyParamCaption}
\item[{{\bf ngram\+\_\+model\+\_\+t} $\ast$}]{set, }
\item[{{\bf ngram\+\_\+model\+\_\+t} $\ast$}]{model, }
\item[{const char $\ast$}]{name, }
\item[{float32}]{weight, }
\item[{int}]{reuse\+\_\+widmap}
\end{DoxyParamCaption}
)}\label{ngram__model_8h_aab34758e97f75733330f3f4cff8a5311}


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-\/\+I\+D mapping in {\ttfamily set}. Any new words present in {\ttfamily model} will not be added to the word-\/\+I\+D 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, ngram\+\_\+model\+\_\+set\+\_\+s\+::lms, logmath\+\_\+log(), ngram\+\_\+model\+\_\+set\+\_\+s\+::lweights, ngram\+\_\+model\+\_\+set\+\_\+s\+::maphist, ngram\+\_\+model\+\_\+s\+::n, ngram\+\_\+model\+\_\+set\+\_\+s\+::n\+\_\+models, ngram\+\_\+model\+\_\+s\+::n\+\_\+words, ngram\+\_\+model\+\_\+set\+\_\+s\+::names, ngram\+\_\+wid(), ngram\+\_\+model\+\_\+set\+\_\+s\+::widmap, and ngram\+\_\+model\+\_\+s\+::word\+\_\+str.

\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}]{\setlength{\rightskip}{0pt plus 5cm}S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T int32 ngram\+\_\+model\+\_\+set\+\_\+current\+\_\+wid (
\begin{DoxyParamCaption}
\item[{{\bf ngram\+\_\+model\+\_\+t} $\ast$}]{set, }
\item[{int32}]{set\+\_\+wid}
\end{DoxyParamCaption}
)}\label{ngram__model_8h_af783553aa7527b7544d093aaea74d97a}


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

\begin{DoxyReturn}{Returns}
the local word I\+D in the current language model, or N\+G\+R\+A\+M\+\_\+\+I\+N\+V\+A\+L\+I\+D\+\_\+\+W\+I\+D 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\+\_\+set\+\_\+s\+::cur, ngram\+\_\+model\+\_\+s\+::n\+\_\+words, N\+G\+R\+A\+M\+\_\+\+I\+N\+V\+A\+L\+I\+D\+\_\+\+W\+I\+D, and ngram\+\_\+model\+\_\+set\+\_\+s\+::widmap.

\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}]{\setlength{\rightskip}{0pt plus 5cm}S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T {\bf ngram\+\_\+model\+\_\+t}$\ast$ ngram\+\_\+model\+\_\+set\+\_\+init (
\begin{DoxyParamCaption}
\item[{{\bf cmd\+\_\+ln\+\_\+t} $\ast$}]{config, }
\item[{{\bf ngram\+\_\+model\+\_\+t} $\ast$$\ast$}]{models, }
\item[{char $\ast$$\ast$}]{names, }
\item[{const float32 $\ast$}]{weights, }
\item[{int32}]{n\+\_\+models}
\end{DoxyParamCaption}
)}\label{ngram__model_8h_a02310e01a48928e1d430aef0ea3c9a99}


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\+L\+L 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\+L\+L 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.



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



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

\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}]{\setlength{\rightskip}{0pt plus 5cm}S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T {\bf ngram\+\_\+model\+\_\+t}$\ast$ ngram\+\_\+model\+\_\+set\+\_\+interp (
\begin{DoxyParamCaption}
\item[{{\bf ngram\+\_\+model\+\_\+t} $\ast$}]{set, }
\item[{const char $\ast$$\ast$}]{names, }
\item[{const float32 $\ast$}]{weights}
\end{DoxyParamCaption}
)}\label{ngram__model_8h_a8a4c853e77c6b48face3a781480e77d6}


Set interpolation weights for a set and enables interpolation. 

If {\ttfamily weights} is N\+U\+L\+L, 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 ngram\+\_\+model\+\_\+set\+\_\+s\+::cur, E\+\_\+\+E\+R\+R\+O\+R, ngram\+\_\+model\+\_\+s\+::lmath, logmath\+\_\+log(), ngram\+\_\+model\+\_\+set\+\_\+s\+::lweights, ngram\+\_\+model\+\_\+set\+\_\+s\+::n\+\_\+models, and ngram\+\_\+model\+\_\+set\+\_\+s\+::names.

\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}]{\setlength{\rightskip}{0pt plus 5cm}S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T {\bf ngram\+\_\+model\+\_\+set\+\_\+iter\+\_\+t}$\ast$ ngram\+\_\+model\+\_\+set\+\_\+iter (
\begin{DoxyParamCaption}
\item[{{\bf ngram\+\_\+model\+\_\+t} $\ast$}]{set}
\end{DoxyParamCaption}
)}\label{ngram__model_8h_a880c7768b082a124e1b6f6f1a764b1e3}


Begin iterating over language models in a set. 

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


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



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

\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}]{\setlength{\rightskip}{0pt plus 5cm}S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T {\bf ngram\+\_\+model\+\_\+t}$\ast$ ngram\+\_\+model\+\_\+set\+\_\+iter\+\_\+model (
\begin{DoxyParamCaption}
\item[{{\bf ngram\+\_\+model\+\_\+set\+\_\+iter\+\_\+t} $\ast$}]{itor, }
\item[{char const $\ast$$\ast$}]{lmname}
\end{DoxyParamCaption}
)}\label{ngram__model_8h_a438592444037281175150e3cf1543052}


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.

\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}]{\setlength{\rightskip}{0pt plus 5cm}S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T {\bf ngram\+\_\+model\+\_\+set\+\_\+iter\+\_\+t}$\ast$ ngram\+\_\+model\+\_\+set\+\_\+iter\+\_\+next (
\begin{DoxyParamCaption}
\item[{{\bf ngram\+\_\+model\+\_\+set\+\_\+iter\+\_\+t} $\ast$}]{itor}
\end{DoxyParamCaption}
)}\label{ngram__model_8h_a038a174f17632703cffce02611149265}


Move to the next language model in a set. 

\begin{DoxyReturn}{Returns}
iterator pointing to the next language model, or N\+U\+L\+L 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().

\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}]{\setlength{\rightskip}{0pt plus 5cm}S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T int32 ngram\+\_\+model\+\_\+set\+\_\+known\+\_\+wid (
\begin{DoxyParamCaption}
\item[{{\bf ngram\+\_\+model\+\_\+t} $\ast$}]{set, }
\item[{int32}]{set\+\_\+wid}
\end{DoxyParamCaption}
)}\label{ngram__model_8h_ad87975912cfe1ac5d0c3ebe12de79209}


Test whether a word I\+D 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\+\_\+set\+\_\+s\+::cur, ngram\+\_\+model\+\_\+set\+\_\+s\+::lms, ngram\+\_\+model\+\_\+set\+\_\+s\+::n\+\_\+models, ngram\+\_\+model\+\_\+s\+::n\+\_\+words, ngram\+\_\+unknown\+\_\+wid(), and ngram\+\_\+model\+\_\+set\+\_\+s\+::widmap.

\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}]{\setlength{\rightskip}{0pt plus 5cm}S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T {\bf ngram\+\_\+model\+\_\+t}$\ast$ ngram\+\_\+model\+\_\+set\+\_\+lookup (
\begin{DoxyParamCaption}
\item[{{\bf ngram\+\_\+model\+\_\+t} $\ast$}]{set, }
\item[{const char $\ast$}]{name}
\end{DoxyParamCaption}
)}\label{ngram__model_8h_a1797a53b95a2a1ca2a6be732918d9fa0}


Look up a language model by name from a set. 

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


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



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

\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}]{\setlength{\rightskip}{0pt plus 5cm}S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T {\bf ngram\+\_\+model\+\_\+t}$\ast$ ngram\+\_\+model\+\_\+set\+\_\+read (
\begin{DoxyParamCaption}
\item[{{\bf cmd\+\_\+ln\+\_\+t} $\ast$}]{config, }
\item[{const char $\ast$}]{lmctlfile, }
\item[{{\bf logmath\+\_\+t} $\ast$}]{lmath}
\end{DoxyParamCaption}
)}\label{ngram__model_8h_afb7b13dbb4a3149b2fa9f7b15dbe35e8}


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-\/\+I\+I and Sphinx-\/\+I\+I\+I. 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.



References ckd\+\_\+calloc, ckd\+\_\+free(), ckd\+\_\+salloc, E\+\_\+\+E\+R\+R\+O\+R, E\+\_\+\+E\+R\+R\+O\+R\+\_\+\+S\+Y\+S\+T\+E\+M, E\+\_\+\+I\+N\+F\+O, glist\+\_\+add\+\_\+ptr(), glist\+\_\+count(), glist\+\_\+free(), glist\+\_\+reverse(), gnode\+\_\+ptr, hash\+\_\+table\+\_\+free(), hash\+\_\+table\+\_\+lookup(), hash\+\_\+table\+\_\+new(), hash\+\_\+table\+\_\+tolist(), N\+G\+R\+A\+M\+\_\+\+A\+U\+T\+O, ngram\+\_\+model\+\_\+add\+\_\+class(), ngram\+\_\+model\+\_\+free(), ngram\+\_\+model\+\_\+read(), ngram\+\_\+model\+\_\+set\+\_\+init(), path\+\_\+is\+\_\+absolute(), string\+\_\+join(), and hash\+\_\+entry\+\_\+s\+::val.

\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}]{\setlength{\rightskip}{0pt plus 5cm}S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T {\bf ngram\+\_\+model\+\_\+t}$\ast$ ngram\+\_\+model\+\_\+set\+\_\+remove (
\begin{DoxyParamCaption}
\item[{{\bf ngram\+\_\+model\+\_\+t} $\ast$}]{set, }
\item[{const char $\ast$}]{name, }
\item[{int}]{reuse\+\_\+widmap}
\end{DoxyParamCaption}
)}\label{ngram__model_8h_af761011a07b87c209e6d174e07b34617}


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-\/\+I\+D mapping in {\ttfamily set}. \\
\hline
\end{DoxyParams}


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



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

\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}]{\setlength{\rightskip}{0pt plus 5cm}S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T {\bf ngram\+\_\+model\+\_\+t}$\ast$ ngram\+\_\+model\+\_\+set\+\_\+select (
\begin{DoxyParamCaption}
\item[{{\bf ngram\+\_\+model\+\_\+t} $\ast$}]{set, }
\item[{const char $\ast$}]{name}
\end{DoxyParamCaption}
)}\label{ngram__model_8h_a5e7a3fd20d32783ce07b760781f658f8}


Select a single language model from a set for scoring. 

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


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



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

\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}]{\setlength{\rightskip}{0pt plus 5cm}S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T int ngram\+\_\+model\+\_\+write (
\begin{DoxyParamCaption}
\item[{{\bf ngram\+\_\+model\+\_\+t} $\ast$}]{model, }
\item[{const char $\ast$}]{file\+\_\+name, }
\item[{{\bf ngram\+\_\+file\+\_\+type\+\_\+t}}]{format}
\end{DoxyParamCaption}
)}\label{ngram__model_8h_ac8ff04e1bccbef23bde9e81fb61c57fe}


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\+O\+R, N\+G\+R\+A\+M\+\_\+\+A\+R\+P\+A, N\+G\+R\+A\+M\+\_\+\+A\+U\+T\+O, N\+G\+R\+A\+M\+\_\+\+D\+M\+P, ngram\+\_\+file\+\_\+name\+\_\+to\+\_\+type(), and N\+G\+R\+A\+M\+\_\+\+I\+N\+V\+A\+L\+I\+D.

\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}]{\setlength{\rightskip}{0pt plus 5cm}S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T int32 ngram\+\_\+ng\+\_\+prob (
\begin{DoxyParamCaption}
\item[{{\bf ngram\+\_\+model\+\_\+t} $\ast$}]{model, }
\item[{int32}]{wid, }
\item[{int32 $\ast$}]{history, }
\item[{int32}]{n\+\_\+hist, }
\item[{int32 $\ast$}]{n\+\_\+used}
\end{DoxyParamCaption}
)}\label{ngram__model_8h_a218d8d140b93d3d8008f8933f9e04ec6}


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\+I\+D, ngram\+\_\+funcs\+\_\+s\+::raw\+\_\+score, and ngram\+\_\+class\+\_\+s\+::tag\+\_\+wid.



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

\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}]{\setlength{\rightskip}{0pt plus 5cm}S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T int32 ngram\+\_\+prob (
\begin{DoxyParamCaption}
\item[{{\bf ngram\+\_\+model\+\_\+t} $\ast$}]{model, }
\item[{const char $\ast$}]{word, }
\item[{}]{...}
\end{DoxyParamCaption}
)}\label{ngram__model_8h_a68cfda3f503e1a4a87f08aa5a3a5ea88}


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.



References ckd\+\_\+calloc, ckd\+\_\+free(), ngram\+\_\+ng\+\_\+prob(), and ngram\+\_\+wid().

\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}]{\setlength{\rightskip}{0pt plus 5cm}S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T int32 ngram\+\_\+score (
\begin{DoxyParamCaption}
\item[{{\bf ngram\+\_\+model\+\_\+t} $\ast$}]{model, }
\item[{const char $\ast$}]{word, }
\item[{}]{...}
\end{DoxyParamCaption}
)}\label{ngram__model_8h_a9c23d79885af400e17ac2a1b7169660d}


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\+L\+L. 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 L\+M and things like that.

If one of the words is not in the L\+M'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\+N\+K$>$ 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.



References ckd\+\_\+calloc, ckd\+\_\+free(), ngram\+\_\+ng\+\_\+score(), and ngram\+\_\+wid().

\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}]{\setlength{\rightskip}{0pt plus 5cm}S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T int32 ngram\+\_\+score\+\_\+to\+\_\+prob (
\begin{DoxyParamCaption}
\item[{{\bf ngram\+\_\+model\+\_\+t} $\ast$}]{model, }
\item[{int32}]{score}
\end{DoxyParamCaption}
)}\label{ngram__model_8h_ae0cf3a94128927e2be6422d2de34f49b}


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, and ngram\+\_\+model\+\_\+s\+::lw.

\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}]{\setlength{\rightskip}{0pt plus 5cm}S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T {\bf ngram\+\_\+file\+\_\+type\+\_\+t} ngram\+\_\+str\+\_\+to\+\_\+type (
\begin{DoxyParamCaption}
\item[{const char $\ast$}]{str\+\_\+name}
\end{DoxyParamCaption}
)}\label{ngram__model_8h_affb3d938049e58c191e72858a7191e9c}


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\+I\+D 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\+P\+A, N\+G\+R\+A\+M\+\_\+\+D\+M\+P, N\+G\+R\+A\+M\+\_\+\+I\+N\+V\+A\+L\+I\+D, and strcmp\+\_\+nocase().

\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}]{\setlength{\rightskip}{0pt plus 5cm}S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T char const$\ast$ ngram\+\_\+type\+\_\+to\+\_\+str (
\begin{DoxyParamCaption}
\item[{int}]{type}
\end{DoxyParamCaption}
)}\label{ngram__model_8h_a992b8a8d7f623e2662ae94991f6aec55}


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\+L\+L if no such type exists. 
\end{DoxyReturn}


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



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

\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}]{\setlength{\rightskip}{0pt plus 5cm}S\+P\+H\+I\+N\+X\+B\+A\+S\+E\+\_\+\+E\+X\+P\+O\+R\+T int32 ngram\+\_\+unknown\+\_\+wid (
\begin{DoxyParamCaption}
\item[{{\bf ngram\+\_\+model\+\_\+t} $\ast$}]{model}
\end{DoxyParamCaption}
)}\label{ngram__model_8h_a1469e9e1c8516a77c9ac1e248a61ef4e}


Get the unknown word I\+D 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\+I\+D.

\begin{DoxyReturn}{Returns}
The I\+D for the unknown word, or N\+G\+R\+A\+M\+\_\+\+I\+N\+V\+A\+L\+I\+D\+\_\+\+W\+I\+D 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\+I\+D, and ngram\+\_\+model\+\_\+s\+::wid.



Referenced by ngram\+\_\+model\+\_\+add\+\_\+class(), ngram\+\_\+model\+\_\+set\+\_\+known\+\_\+wid(), and ngram\+\_\+wid().

