<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <title>PocketSphinx: src/libpocketsphinx/dict.h Source File</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="navtree.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="navtree.js"></script> <script type="text/javascript" src="resize.js"></script> <script type="text/javascript"> $(document).ready(initResizable); </script> <link href="doxygen.css" rel="stylesheet" type="text/css"/> </head> <body> <!-- Generated by Doxygen 1.7.3 --> <div id="top"> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td style="padding-left: 0.5em;"> <div id="projectname">PocketSphinx <span id="projectnumber">0.6</span></div> </td> </tr> </tbody> </table> </div> <div id="navrow1" class="tabs"> <ul class="tablist"> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="annotated.html"><span>Data Structures</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> </ul> </div> <div id="navrow2" class="tabs2"> <ul class="tablist"> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>Globals</span></a></li> </ul> </div> </div> <div id="side-nav" class="ui-resizable side-nav-resizable"> <div id="nav-tree"> <div id="nav-tree-contents"> </div> </div> <div id="splitbar" style="-moz-user-select:none;" class="ui-resizable-handle"> </div> </div> <script type="text/javascript"> initNavTree('dict_8h.html',''); </script> <div id="doc-content"> <div class="header"> <div class="headertitle"> <h1>src/libpocketsphinx/dict.h</h1> </div> </div> <div class="contents"> <a href="dict_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */</span> <a name="l00002"></a>00002 <span class="comment">/* ====================================================================</span> <a name="l00003"></a>00003 <span class="comment"> * Copyright (c) 1999-2004 Carnegie Mellon University. All rights</span> <a name="l00004"></a>00004 <span class="comment"> * reserved.</span> <a name="l00005"></a>00005 <span class="comment"> *</span> <a name="l00006"></a>00006 <span class="comment"> * Redistribution and use in source and binary forms, with or without</span> <a name="l00007"></a>00007 <span class="comment"> * modification, are permitted provided that the following conditions</span> <a name="l00008"></a>00008 <span class="comment"> * are met:</span> <a name="l00009"></a>00009 <span class="comment"> *</span> <a name="l00010"></a>00010 <span class="comment"> * 1. Redistributions of source code must retain the above copyright</span> <a name="l00011"></a>00011 <span class="comment"> * notice, this list of conditions and the following disclaimer. </span> <a name="l00012"></a>00012 <span class="comment"> *</span> <a name="l00013"></a>00013 <span class="comment"> * 2. Redistributions in binary form must reproduce the above copyright</span> <a name="l00014"></a>00014 <span class="comment"> * notice, this list of conditions and the following disclaimer in</span> <a name="l00015"></a>00015 <span class="comment"> * the documentation and/or other materials provided with the</span> <a name="l00016"></a>00016 <span class="comment"> * distribution.</span> <a name="l00017"></a>00017 <span class="comment"> *</span> <a name="l00018"></a>00018 <span class="comment"> * This work was supported in part by funding from the Defense Advanced </span> <a name="l00019"></a>00019 <span class="comment"> * Research Projects Agency and the National Science Foundation of the </span> <a name="l00020"></a>00020 <span class="comment"> * United States of America, and the CMU Sphinx Speech Consortium.</span> <a name="l00021"></a>00021 <span class="comment"> *</span> <a name="l00022"></a>00022 <span class="comment"> * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND </span> <a name="l00023"></a>00023 <span class="comment"> * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, </span> <a name="l00024"></a>00024 <span class="comment"> * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR</span> <a name="l00025"></a>00025 <span class="comment"> * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY</span> <a name="l00026"></a>00026 <span class="comment"> * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,</span> <a name="l00027"></a>00027 <span class="comment"> * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT </span> <a name="l00028"></a>00028 <span class="comment"> * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, </span> <a name="l00029"></a>00029 <span class="comment"> * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY </span> <a name="l00030"></a>00030 <span class="comment"> * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT </span> <a name="l00031"></a>00031 <span class="comment"> * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE </span> <a name="l00032"></a>00032 <span class="comment"> * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</span> <a name="l00033"></a>00033 <span class="comment"> *</span> <a name="l00034"></a>00034 <span class="comment"> * ====================================================================</span> <a name="l00035"></a>00035 <span class="comment"> *</span> <a name="l00036"></a>00036 <span class="comment"> */</span> <a name="l00037"></a>00037 <a name="l00038"></a>00038 <span class="preprocessor">#ifndef _S3_DICT_H_</span> <a name="l00039"></a>00039 <span class="preprocessor"></span><span class="preprocessor">#define _S3_DICT_H_</span> <a name="l00040"></a>00040 <span class="preprocessor"></span> <a name="l00045"></a>00045 <span class="comment">/* SphinxBase headers. */</span> <a name="l00046"></a>00046 <span class="preprocessor">#include <sphinxbase/hash_table.h></span> <a name="l00047"></a>00047 <a name="l00048"></a>00048 <span class="comment">/* Local headers. */</span> <a name="l00049"></a>00049 <span class="preprocessor">#include "<a class="code" href="s3types_8h.html" title="Size definition of semantically units.">s3types.h</a>"</span> <a name="l00050"></a>00050 <span class="preprocessor">#include "<a class="code" href="bin__mdef_8h.html" title="Binary format model definition files, with support for heterogeneous topologies and variable-size N-p...">bin_mdef.h</a>"</span> <a name="l00051"></a>00051 <span class="preprocessor">#include "pocketsphinx_export.h"</span> <a name="l00052"></a>00052 <a name="l00053"></a>00053 <span class="preprocessor">#define S3DICT_INC_SZ 4096</span> <a name="l00054"></a>00054 <span class="preprocessor"></span> <a name="l00055"></a>00055 <span class="preprocessor">#ifdef __cplusplus</span> <a name="l00056"></a>00056 <span class="preprocessor"></span><span class="keyword">extern</span> <span class="stringliteral">"C"</span> { <a name="l00057"></a>00057 <span class="preprocessor">#endif</span> <a name="l00058"></a>00058 <span class="preprocessor"></span><span class="preprocessor">#if 0</span> <a name="l00059"></a>00059 <span class="preprocessor"></span>} <span class="comment">/* Fool Emacs into not indenting things. */</span> <a name="l00060"></a>00060 <span class="preprocessor">#endif</span> <a name="l00061"></a>00061 <span class="preprocessor"></span> <a name="l00066"></a><a class="code" href="structdictword__t.html">00066</a> <span class="keyword">typedef</span> <span class="keyword">struct </span>{ <a name="l00067"></a><a class="code" href="structdictword__t.html#a3f3371918a406e26817bd4f2cecd7329">00067</a> <span class="keywordtype">char</span> *<a class="code" href="structdictword__t.html#a3f3371918a406e26817bd4f2cecd7329" title="Ascii word string.">word</a>; <a name="l00068"></a><a class="code" href="structdictword__t.html#acf5836b5a681485868e9090ad67366d5">00068</a> <a class="code" href="s3types_8h.html#ae5f70241ce62a79747f0611029a6409d" title="Size definitions for more semantially meaningful units.">s3cipid_t</a> *<a class="code" href="structdictword__t.html#acf5836b5a681485868e9090ad67366d5" title="Pronunciation.">ciphone</a>; <a name="l00069"></a><a class="code" href="structdictword__t.html#a50509f28a4b64d76519bfadea12f0fa0">00069</a> int32 <a class="code" href="structdictword__t.html#a50509f28a4b64d76519bfadea12f0fa0" title="Pronunciation length.">pronlen</a>; <a name="l00070"></a><a class="code" href="structdictword__t.html#a84b63cd03706221645f46b2da09e9540">00070</a> s3wid_t <a class="code" href="structdictword__t.html#a84b63cd03706221645f46b2da09e9540" title="Next alternative pronunciation id, NOT_S3WID if none.">alt</a>; <a name="l00071"></a><a class="code" href="structdictword__t.html#a53dd72f96a9de21d8925e246cc7c036f">00071</a> s3wid_t <a class="code" href="structdictword__t.html#a53dd72f96a9de21d8925e246cc7c036f" title="Base pronunciation id.">basewid</a>; <a name="l00072"></a>00072 } <a class="code" href="structdictword__t.html" title="a structure for one dictionary word.">dictword_t</a>; <a name="l00073"></a>00073 <a name="l00079"></a><a class="code" href="structdict__t.html">00079</a> <span class="keyword">typedef</span> <span class="keyword">struct </span>{ <a name="l00080"></a>00080 <span class="keywordtype">int</span> refcnt; <a name="l00081"></a><a class="code" href="structdict__t.html#a3a01eb5a3ebda5652d434be26e0cfdd2">00081</a> <a class="code" href="structbin__mdef__s.html">bin_mdef_t</a> *<a class="code" href="structdict__t.html#a3a01eb5a3ebda5652d434be26e0cfdd2" title="Model definition used for phone IDs; NULL if none used.">mdef</a>; <a name="l00082"></a><a class="code" href="structdict__t.html#a9e6636bbe45936a03381fea430addd31">00082</a> <a class="code" href="structdictword__t.html" title="a structure for one dictionary word.">dictword_t</a> *<a class="code" href="structdict__t.html#a9e6636bbe45936a03381fea430addd31" title="Array of entries in dictionary.">word</a>; <a name="l00083"></a><a class="code" href="structdict__t.html#a7205aae4fbeef3aaa53f94b6af529af2">00083</a> hash_table_t *<a class="code" href="structdict__t.html#a7205aae4fbeef3aaa53f94b6af529af2" title="Hash table for mapping word strings to word ids.">ht</a>; <a name="l00084"></a><a class="code" href="structdict__t.html#af6142600cef73f846b58ba9bc36b02ac">00084</a> int32 <a class="code" href="structdict__t.html#af6142600cef73f846b58ba9bc36b02ac" title="#Entries allocated in dict, including empty slots">max_words</a>; <a name="l00085"></a><a class="code" href="structdict__t.html#af00f60319a7025361e291af5addb6b31">00085</a> int32 <a class="code" href="structdict__t.html#af00f60319a7025361e291af5addb6b31" title="#Occupied entries in dict; ie, excluding empty slots">n_word</a>; <a name="l00086"></a><a class="code" href="structdict__t.html#abd48fdafaaa68a8df2fd82163c51a95c">00086</a> int32 <a class="code" href="structdict__t.html#abd48fdafaaa68a8df2fd82163c51a95c" title="First filler word id (read from filler dict)">filler_start</a>; <a name="l00087"></a><a class="code" href="structdict__t.html#a77c6692e56308968804add1292275cb7">00087</a> int32 <a class="code" href="structdict__t.html#a77c6692e56308968804add1292275cb7" title="Last filler word id (read from filler dict)">filler_end</a>; <a name="l00088"></a><a class="code" href="structdict__t.html#a22bc6c52ce9e04c4f3f7d0ba1972ee51">00088</a> s3wid_t <a class="code" href="structdict__t.html#a22bc6c52ce9e04c4f3f7d0ba1972ee51" title="FOR INTERNAL-USE ONLY.">startwid</a>; <a name="l00089"></a><a class="code" href="structdict__t.html#a3875be5336e2d9888f6d5cb83ded82c5">00089</a> s3wid_t <a class="code" href="structdict__t.html#a3875be5336e2d9888f6d5cb83ded82c5" title="FOR INTERNAL-USE ONLY.">finishwid</a>; <a name="l00090"></a><a class="code" href="structdict__t.html#aad07b22b94c360923f151c02890f6e68">00090</a> s3wid_t <a class="code" href="structdict__t.html#aad07b22b94c360923f151c02890f6e68" title="FOR INTERNAL-USE ONLY.">silwid</a>; <a name="l00091"></a>00091 <span class="keywordtype">int</span> nocase; <a name="l00092"></a>00092 } <a class="code" href="structdict__t.html" title="a structure for a dictionary.">dict_t</a>; <a name="l00093"></a>00093 <a name="l00094"></a>00094 <a name="l00106"></a>00106 <a class="code" href="structdict__t.html" title="a structure for a dictionary.">dict_t</a> *dict_init(cmd_ln_t *config, <a name="l00107"></a>00107 <a class="code" href="structbin__mdef__s.html">bin_mdef_t</a> *mdef <a name="l00108"></a>00108 ); <a name="l00109"></a>00109 <a name="l00113"></a>00113 <span class="keywordtype">int</span> dict_write(<a class="code" href="structdict__t.html" title="a structure for a dictionary.">dict_t</a> *dict, <span class="keywordtype">char</span> <span class="keyword">const</span> *filename, <span class="keywordtype">char</span> <span class="keyword">const</span> *format); <a name="l00114"></a>00114 <a name="l00116"></a>00116 POCKETSPHINX_EXPORT <a name="l00117"></a>00117 s3wid_t dict_wordid(<a class="code" href="structdict__t.html" title="a structure for a dictionary.">dict_t</a> *d, <span class="keyword">const</span> <span class="keywordtype">char</span> *word); <a name="l00118"></a>00118 <a name="l00123"></a>00123 <span class="keywordtype">int</span> dict_filler_word(<a class="code" href="structdict__t.html" title="a structure for a dictionary.">dict_t</a> *d, <a name="l00124"></a>00124 s3wid_t w <a name="l00125"></a>00125 ); <a name="l00126"></a>00126 <a name="l00130"></a>00130 POCKETSPHINX_EXPORT <a name="l00131"></a>00131 <span class="keywordtype">int</span> dict_real_word(<a class="code" href="structdict__t.html" title="a structure for a dictionary.">dict_t</a> *d, <a name="l00132"></a>00132 s3wid_t w <a name="l00133"></a>00133 ); <a name="l00134"></a>00134 <a name="l00139"></a>00139 s3wid_t dict_add_word(<a class="code" href="structdict__t.html" title="a structure for a dictionary.">dict_t</a> *d, <a name="l00140"></a>00140 <span class="keywordtype">char</span> <span class="keyword">const</span> *word, <a name="l00141"></a>00141 <a class="code" href="s3types_8h.html#ae5f70241ce62a79747f0611029a6409d" title="Size definitions for more semantially meaningful units.">s3cipid_t</a> <span class="keyword">const</span> *p, <a name="l00142"></a>00142 int32 np <a name="l00143"></a>00143 ); <a name="l00144"></a>00144 <a name="l00148"></a>00148 <span class="keyword">const</span> <span class="keywordtype">char</span> *dict_ciphone_str(<a class="code" href="structdict__t.html" title="a structure for a dictionary.">dict_t</a> *d, <a name="l00149"></a>00149 s3wid_t wid, <a name="l00150"></a>00150 int32 pos <a name="l00151"></a>00151 ); <a name="l00152"></a>00152 <a name="l00154"></a><a class="code" href="dict_8h.html#a361b948b42f9cfdf5c7fa9dfc8a71a94">00154</a> <span class="preprocessor">#define dict_size(d) ((d)->n_word)</span> <a name="l00155"></a>00155 <span class="preprocessor"></span><span class="preprocessor">#define dict_num_fillers(d) (dict_filler_end(d) - dict_filler_start(d))</span> <a name="l00156"></a>00156 <span class="preprocessor"></span> <a name="l00161"></a><a class="code" href="dict_8h.html#a529d92f69f39e1f8c4a94e60a9509201">00161</a> <span class="preprocessor">#define dict_num_real_words(d) \</span> <a name="l00162"></a>00162 <span class="preprocessor"> (dict_size(d) - (dict_filler_end(d) - dict_filler_start(d)) - 2)</span> <a name="l00163"></a>00163 <span class="preprocessor"></span><span class="preprocessor">#define dict_basewid(d,w) ((d)->word[w].basewid)</span> <a name="l00164"></a>00164 <span class="preprocessor"></span><span class="preprocessor">#define dict_wordstr(d,w) ((w) < 0 ? NULL : (d)->word[w].word)</span> <a name="l00165"></a>00165 <span class="preprocessor"></span><span class="preprocessor">#define dict_basestr(d,w) ((d)->word[dict_basewid(d,w)].word)</span> <a name="l00166"></a>00166 <span class="preprocessor"></span><span class="preprocessor">#define dict_nextalt(d,w) ((d)->word[w].alt)</span> <a name="l00167"></a>00167 <span class="preprocessor"></span><span class="preprocessor">#define dict_pronlen(d,w) ((d)->word[w].pronlen) </span> <a name="l00168"></a><a class="code" href="dict_8h.html#a8785ab6264a5c6cf0b8da6bf79a46de4">00168</a> <span class="preprocessor"></span><span class="preprocessor">#define dict_pron(d,w,p) ((d)->word[w].ciphone[p]) </span> <a name="l00169"></a>00169 <span class="preprocessor">#define dict_filler_start(d) ((d)->filler_start)</span> <a name="l00170"></a>00170 <span class="preprocessor"></span><span class="preprocessor">#define dict_filler_end(d) ((d)->filler_end)</span> <a name="l00171"></a>00171 <span class="preprocessor"></span><span class="preprocessor">#define dict_startwid(d) ((d)->startwid)</span> <a name="l00172"></a>00172 <span class="preprocessor"></span><span class="preprocessor">#define dict_finishwid(d) ((d)->finishwid)</span> <a name="l00173"></a>00173 <span class="preprocessor"></span><span class="preprocessor">#define dict_silwid(d) ((d)->silwid)</span> <a name="l00174"></a>00174 <span class="preprocessor"></span><span class="preprocessor">#define dict_is_single_phone(d,w) ((d)->word[w].pronlen == 1)</span> <a name="l00175"></a>00175 <span class="preprocessor"></span><span class="preprocessor">#define dict_first_phone(d,w) ((d)->word[w].ciphone[0])</span> <a name="l00176"></a>00176 <span class="preprocessor"></span><span class="preprocessor">#define dict_second_phone(d,w) ((d)->word[w].ciphone[1])</span> <a name="l00177"></a>00177 <span class="preprocessor"></span><span class="preprocessor">#define dict_second_last_phone(d,w) ((d)->word[w].ciphone[(d)->word[w].pronlen - 2])</span> <a name="l00178"></a>00178 <span class="preprocessor"></span><span class="preprocessor">#define dict_last_phone(d,w) ((d)->word[w].ciphone[(d)->word[w].pronlen - 1])</span> <a name="l00179"></a>00179 <span class="preprocessor"></span> <a name="l00180"></a>00180 <span class="comment">/* Hard-coded special words */</span> <a name="l00181"></a>00181 <span class="preprocessor">#define S3_START_WORD "<s>"</span> <a name="l00182"></a>00182 <span class="preprocessor"></span><span class="preprocessor">#define S3_FINISH_WORD "</s>"</span> <a name="l00183"></a>00183 <span class="preprocessor"></span><span class="preprocessor">#define S3_SILENCE_WORD "<sil>"</span> <a name="l00184"></a>00184 <span class="preprocessor"></span><span class="preprocessor">#define S3_UNKNOWN_WORD "<UNK>"</span> <a name="l00185"></a>00185 <span class="preprocessor"></span> <a name="l00193"></a>00193 int32 dict_word2basestr(<span class="keywordtype">char</span> *word); <a name="l00194"></a>00194 <a name="l00198"></a>00198 <a class="code" href="structdict__t.html" title="a structure for a dictionary.">dict_t</a> *dict_retain(<a class="code" href="structdict__t.html" title="a structure for a dictionary.">dict_t</a> *d); <a name="l00199"></a>00199 <a name="l00203"></a>00203 <span class="keywordtype">int</span> dict_free(<a class="code" href="structdict__t.html" title="a structure for a dictionary.">dict_t</a> *d); <a name="l00204"></a>00204 <a name="l00206"></a>00206 <span class="keywordtype">void</span> dict_report(<a class="code" href="structdict__t.html" title="a structure for a dictionary.">dict_t</a> *d <a name="l00207"></a>00207 ); <a name="l00208"></a>00208 <a name="l00209"></a>00209 <span class="preprocessor">#if 0</span> <a name="l00210"></a>00210 <span class="preprocessor"></span>{ <span class="comment">/* Stop indent from complaining */</span> <a name="l00211"></a>00211 <span class="preprocessor">#endif</span> <a name="l00212"></a>00212 <span class="preprocessor"></span><span class="preprocessor">#ifdef __cplusplus</span> <a name="l00213"></a>00213 <span class="preprocessor"></span>} <a name="l00214"></a>00214 <span class="preprocessor">#endif</span> <a name="l00215"></a>00215 <span class="preprocessor"></span> <a name="l00216"></a>00216 <span class="preprocessor">#endif</span> </pre></div></div> </div> <div id="nav-path" class="navpath"> <ul> <li class="navelem"><a class="el" href="dict_8h.html">dict.h</a> </li> <li class="footer">Generated on Wed Apr 20 2011 for PocketSphinx by  <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.3 </li> </ul> </div> </body> </html>