PocketSphinx  0.6
src/libpocketsphinx/dict2pid.h
Go to the documentation of this file.
00001 /* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */
00002 /* ====================================================================
00003  * Copyright (c) 1999-2004 Carnegie Mellon University.  All rights
00004  * reserved.
00005  *
00006  * Redistribution and use in source and binary forms, with or without
00007  * modification, are permitted provided that the following conditions
00008  * are met:
00009  *
00010  * 1. Redistributions of source code must retain the above copyright
00011  *    notice, this list of conditions and the following disclaimer. 
00012  *
00013  * 2. Redistributions in binary form must reproduce the above copyright
00014  *    notice, this list of conditions and the following disclaimer in
00015  *    the documentation and/or other materials provided with the
00016  *    distribution.
00017  *
00018  * This work was supported in part by funding from the Defense Advanced 
00019  * Research Projects Agency and the National Science Foundation of the 
00020  * United States of America, and the CMU Sphinx Speech Consortium.
00021  *
00022  * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND 
00023  * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
00024  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00025  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY
00026  * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00027  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
00028  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
00029  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
00030  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
00031  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
00032  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00033  *
00034  * ====================================================================
00035  *
00036  */
00037 /*
00038  * dict2pid.h -- Triphones for dictionary
00039  * 
00040  * **********************************************
00041  * CMU ARPA Speech Project
00042  *
00043  * Copyright (c) 1999 Carnegie Mellon University.
00044  * ALL RIGHTS RESERVED.
00045  * **********************************************
00046  * 
00047  * HISTORY
00048  * $Log$
00049  * Revision 1.1  2006/04/05  20:27:30  dhdfu
00050  * A Great Reorganzation of header files and executables
00051  * 
00052  * Revision 1.9  2006/02/22 21:05:16  arthchan2003
00053  * Merged from branch SPHINX3_5_2_RCI_IRII_BRANCH:
00054  *
00055  * 1, Added logic to handle bothe composite and non composite left
00056  * triphone.  Composite left triphone's logic (the original one) is
00057  * tested thoroughly. The non-composite triphone (or full triphone) is
00058  * found to have bugs.  The latter is fended off from the users in the
00059  * library level.
00060  *
00061  * 2, Fixed dox-doc.
00062  *
00063  * Revision 1.8.4.5  2005/11/17 06:13:49  arthchan2003
00064  * Use compressed right context in expansion in triphones.
00065  *
00066  * Revision 1.8.4.4  2005/10/17 04:48:45  arthchan2003
00067  * Free resource correctly in dict2pid.
00068  *
00069  * Revision 1.8.4.3  2005/10/07 19:03:38  arthchan2003
00070  * Added xwdssid_t structure.  Also added compression routines.
00071  *
00072  * Revision 1.8.4.2  2005/09/25 19:13:31  arthchan2003
00073  * Added optional full triphone expansion support when building context phone mapping.
00074  *
00075  * Revision 1.8.4.1  2005/07/17 05:20:30  arthchan2003
00076  * Fixed dox-doc.
00077  *
00078  * Revision 1.8  2005/06/21 21:03:49  arthchan2003
00079  * 1, Introduced a reporting routine. 2, Fixed doyxgen documentation, 3, Added  keyword.
00080  *
00081  * Revision 1.5  2005/06/13 04:02:57  archan
00082  * Fixed most doxygen-style documentation under libs3decoder.
00083  *
00084  * Revision 1.4  2005/04/21 23:50:26  archan
00085  * Some more refactoring on the how reporting of structures inside kbcore_t is done, it is now 50% nice. Also added class-based LM test case into test-decode.sh.in.  At this moment, everything in search mode 5 is already done.  It is time to test the idea whether the search can really be used.
00086  *
00087  * Revision 1.3  2005/03/30 01:22:46  archan
00088  * Fixed mistakes in last updates. Add
00089  *
00090  * 
00091  * 14-Sep-1999  M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University
00092  *              Added dict2pid_comsseq2sen_active().
00093  * 
00094  * 04-May-1999  M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University
00095  *              Started.
00096  */
00097 
00098 
00099 #ifndef _S3_DICT2PID_H_
00100 #define _S3_DICT2PID_H_
00101 
00102 /* System headers. */
00103 #include <stdio.h>
00104 
00105 /* SphinxBase headers. */
00106 #include <sphinxbase/logmath.h>
00107 #include <sphinxbase/bitvec.h>
00108 
00109 /* Local headers. */
00110 #include "s3types.h"
00111 #include "bin_mdef.h"
00112 #include "dict.h"
00113 
00125 #ifdef __cplusplus
00126 extern "C" {
00127 #endif
00128 #if 0
00129 } /* Fool Emacs into not indenting things. */
00130 #endif
00131 
00137 typedef struct {
00138     s3ssid_t  *ssid;    
00139     s3cipid_t *cimap;   
00140     int32     n_ssid;   
00141 } xwdssid_t;
00142 
00148 typedef struct {
00149     int refcount;
00150 
00151     bin_mdef_t *mdef;           
00153     dict_t *dict;               
00155     /*Notice the order of the arguments */
00156     /* FIXME: This is crying out for compression - in Mandarin we have
00157      * 180 context independent phones, which makes this an 11MB
00158      * array. */
00159     s3ssid_t ***ldiph_lc;       
00163     xwdssid_t **rssid;          
00169     s3ssid_t ***lrdiph_rc;      
00172     xwdssid_t **lrssid;          
00176 } dict2pid_t;
00177 
00179 #define dict2pid_rssid(d,ci,lc)  (&(d)->rssid[ci][lc])
00180 #define dict2pid_ldiph_lc(d,b,r,l) ((d)->ldiph_lc[b][r][l])
00181 #define dict2pid_lrdiph_rc(d,b,l,r) ((d)->lrdiph_rc[b][l][r])
00182 
00186 dict2pid_t *dict2pid_build(bin_mdef_t *mdef,   
00187                            dict_t *dict        
00188     );
00189 
00193 dict2pid_t *dict2pid_retain(dict2pid_t *d2p);  
00194 
00198 int dict2pid_free(dict2pid_t *d2p 
00199     );
00200 
00204 s3ssid_t dict2pid_internal(dict2pid_t *d2p,
00205                            int32 wid,
00206                            int pos);
00207 
00211 int dict2pid_add_word(dict2pid_t *d2p,
00212                       int32 wid);
00213 
00217 void dict2pid_dump(FILE *fp,        
00218                    dict2pid_t *d2p 
00219     );
00220 
00222 void dict2pid_report(dict2pid_t *d2p 
00223     );
00224 
00228 int32 get_rc_nssid(dict2pid_t *d2p,  
00229                    s3wid_t w         
00230     );
00231 
00235 s3cipid_t* dict2pid_get_rcmap(dict2pid_t *d2p,  
00236                               s3wid_t w        
00237     );
00238 
00239 #if 0
00240 { /* Stop indent from complaining */
00241 #endif
00242 #ifdef __cplusplus
00243 }
00244 #endif
00245 
00246 
00247 #endif