PocketSphinx  0.6
dict2pid.h
Go to the documentation of this file.
1 /* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */
2 /* ====================================================================
3  * Copyright (c) 1999-2004 Carnegie Mellon University. All rights
4  * reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  *
13  * 2. Redistributions in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following disclaimer in
15  * the documentation and/or other materials provided with the
16  * distribution.
17  *
18  * This work was supported in part by funding from the Defense Advanced
19  * Research Projects Agency and the National Science Foundation of the
20  * United States of America, and the CMU Sphinx Speech Consortium.
21  *
22  * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND
23  * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
24  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
25  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY
26  * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  *
34  * ====================================================================
35  *
36  */
37 /*
38  * dict2pid.h -- Triphones for dictionary
39  *
40  * **********************************************
41  * CMU ARPA Speech Project
42  *
43  * Copyright (c) 1999 Carnegie Mellon University.
44  * ALL RIGHTS RESERVED.
45  * **********************************************
46  *
47  * HISTORY
48  * $Log$
49  * Revision 1.1 2006/04/05 20:27:30 dhdfu
50  * A Great Reorganzation of header files and executables
51  *
52  * Revision 1.9 2006/02/22 21:05:16 arthchan2003
53  * Merged from branch SPHINX3_5_2_RCI_IRII_BRANCH:
54  *
55  * 1, Added logic to handle bothe composite and non composite left
56  * triphone. Composite left triphone's logic (the original one) is
57  * tested thoroughly. The non-composite triphone (or full triphone) is
58  * found to have bugs. The latter is fended off from the users in the
59  * library level.
60  *
61  * 2, Fixed dox-doc.
62  *
63  * Revision 1.8.4.5 2005/11/17 06:13:49 arthchan2003
64  * Use compressed right context in expansion in triphones.
65  *
66  * Revision 1.8.4.4 2005/10/17 04:48:45 arthchan2003
67  * Free resource correctly in dict2pid.
68  *
69  * Revision 1.8.4.3 2005/10/07 19:03:38 arthchan2003
70  * Added xwdssid_t structure. Also added compression routines.
71  *
72  * Revision 1.8.4.2 2005/09/25 19:13:31 arthchan2003
73  * Added optional full triphone expansion support when building context phone mapping.
74  *
75  * Revision 1.8.4.1 2005/07/17 05:20:30 arthchan2003
76  * Fixed dox-doc.
77  *
78  * Revision 1.8 2005/06/21 21:03:49 arthchan2003
79  * 1, Introduced a reporting routine. 2, Fixed doyxgen documentation, 3, Added keyword.
80  *
81  * Revision 1.5 2005/06/13 04:02:57 archan
82  * Fixed most doxygen-style documentation under libs3decoder.
83  *
84  * Revision 1.4 2005/04/21 23:50:26 archan
85  * 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.
86  *
87  * Revision 1.3 2005/03/30 01:22:46 archan
88  * Fixed mistakes in last updates. Add
89  *
90  *
91  * 14-Sep-1999 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University
92  * Added dict2pid_comsseq2sen_active().
93  *
94  * 04-May-1999 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University
95  * Started.
96  */
97 
98 
99 #ifndef _S3_DICT2PID_H_
100 #define _S3_DICT2PID_H_
101 
102 /* System headers. */
103 #include <stdio.h>
104 
105 /* SphinxBase headers. */
106 #include <sphinxbase/logmath.h>
107 #include <sphinxbase/bitvec.h>
108 
109 /* Local headers. */
110 #include "s3types.h"
111 #include "bin_mdef.h"
112 #include "dict.h"
113 
125 #ifdef __cplusplus
126 extern "C" {
127 #endif
128 #if 0
129 } /* Fool Emacs into not indenting things. */
130 #endif
131 
137 typedef struct {
138  s3ssid_t *ssid;
140  int32 n_ssid;
141 } xwdssid_t;
142 
148 typedef struct {
149  int refcount;
150 
155  /*Notice the order of the arguments */
156  /* FIXME: This is crying out for compression - in Mandarin we have
157  * 180 context independent phones, which makes this an 11MB
158  * array. */
159  s3ssid_t ***ldiph_lc;
169  s3ssid_t ***lrdiph_rc;
176 } dict2pid_t;
177 
179 #define dict2pid_rssid(d,ci,lc) (&(d)->rssid[ci][lc])
180 #define dict2pid_ldiph_lc(d,b,r,l) ((d)->ldiph_lc[b][r][l])
181 #define dict2pid_lrdiph_rc(d,b,l,r) ((d)->lrdiph_rc[b][l][r])
182 
187  dict_t *dict
188  );
189 
194 
198 int dict2pid_free(dict2pid_t *d2p
199  );
200 
204 s3ssid_t dict2pid_internal(dict2pid_t *d2p,
205  int32 wid,
206  int pos);
207 
212  int32 wid);
213 
217 void dict2pid_dump(FILE *fp,
218  dict2pid_t *d2p
219  );
220 
222 void dict2pid_report(dict2pid_t *d2p
223  );
224 
228 int32 get_rc_nssid(dict2pid_t *d2p,
229  s3wid_t w
230  );
231 
236  s3wid_t w
237  );
238 
239 #if 0
240 { /* Stop indent from complaining */
241 #endif
242 #ifdef __cplusplus
243 }
244 #endif
245 
246 
247 #endif
void dict2pid_report(dict2pid_t *d2p)
Report a dict2pid data structure.
Definition: dict2pid.c:533
int dict2pid_free(dict2pid_t *d2p)
Free the memory dict2pid structure.
Definition: dict2pid.c:507
Operations on dictionary.
s3ssid_t *** ldiph_lc
For multi-phone words, [base][rc][lc] -> ssid; filled out for word-initial base x rc combinations in ...
Definition: dict2pid.h:159
int32 n_ssid
#Unique ssid in above, compressed ssid list
Definition: dict2pid.h:140
Binary format model definition files, with support for heterogeneous topologies and variable-size N-p...
xwdssid_t ** rssid
Right context state sequence id table First dimension: base phone, Second dimension: left context...
Definition: dict2pid.h:163
void dict2pid_dump(FILE *fp, dict2pid_t *d2p)
For debugging.
Definition: dict2pid.c:538
int16 s3cipid_t
Size definitions for more semantially meaningful units.
Definition: s3types.h:109
bin_mdef_t * mdef
Model definition, used to generate internal ssids on the fly.
Definition: dict2pid.h:151
Size definition of semantically units.
dict2pid_t * dict2pid_retain(dict2pid_t *d2p)
Retain a pointer to dict2pid.
Definition: dict2pid.c:500
s3ssid_t *** lrdiph_rc
For single-phone words, [base][lc][rc] -> ssid; filled out for single-phone base x lc combinations in...
Definition: dict2pid.h:169
dict_t * dict
Dictionary this table refers to.
Definition: dict2pid.h:153
a structure for a dictionary.
Definition: dict.h:79
s3cipid_t * dict2pid_get_rcmap(dict2pid_t *d2p, s3wid_t w)
Get RC map.
Definition: dict2pid.c:229
cross word triphone model structure
Definition: dict2pid.h:137
int32 get_rc_nssid(dict2pid_t *d2p, s3wid_t w)
Get number of rc.
Definition: dict2pid.c:204
xwdssid_t ** lrssid
Left-Right context state sequence id table First dimension: base phone, Second dimension: left contex...
Definition: dict2pid.h:172
int dict2pid_add_word(dict2pid_t *d2p, int32 wid)
Add a word to the dict2pid structure (after adding it to dict).
Definition: dict2pid.c:298
dict2pid_t * dict2pid_build(bin_mdef_t *mdef, dict_t *dict)
Build the dict2pid structure for the given model/dictionary.
Definition: dict2pid.c:388
s3ssid_t dict2pid_internal(dict2pid_t *d2p, int32 wid, int pos)
Return the senone sequence ID for the given word position.
Definition: dict2pid.c:367
s3cipid_t * cimap
Index into ssid[] above for each ci phone.
Definition: dict2pid.h:139
Building composite triphone (as well as word internal triphones) with the dictionary.
Definition: dict2pid.h:148
s3ssid_t * ssid
Senone Sequence ID list for all context ciphones.
Definition: dict2pid.h:138