ctxt_table.h
Go to the documentation of this file.
1 /* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */
2 /* ====================================================================
3  * Copyright (c) 1995-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  * ctxt_table.h -- Phone Context Table Structure
39  *
40  * **********************************************
41  * CMU ARPA Speech Project
42  *
43  * Copyright (c) 1995 Carnegie Mellon University.
44  * ALL RIGHTS RESERVED.
45  * **********************************************
46  * 14-Jul-05 ARCHAN (archan@cs.cmu.edu) at Carnegie Mellon Unversity
47  * First created it.
48  *
49  * $Log$
50  * Revision 1.1 2006/04/05 20:27:30 dhdfu
51  * A Great Reorganzation of header files and executables
52  *
53  * Revision 1.2 2006/02/22 20:46:05 arthchan2003
54  * Merged from branch SPHINX3_5_2_RCI_IRII_BRANCH: ctxt_table is a wrapper of the triphone context structure and its maniuplations which were used in flat_fwd.c . The original flat_fwd.c was very long (3000) lines. It was broken in 5 parts, ctxt_table is one of the 5.
55  *
56  * Revision 1.1.2.2 2005/09/27 07:39:17 arthchan2003
57  * Added ctxt_table_free.
58  *
59  * Revision 1.1.2.1 2005/09/25 19:08:25 arthchan2003
60  * Move context table from search to here.
61  *
62  * Revision 1.1.2.3 2005/09/07 23:32:03 arthchan2003
63  * 1, Added get_lcpid in parrallel with get_rcpid. 2, Also fixed small mistakes in the macro.
64  *
65  * Revision 1.1.2.2 2005/07/17 05:42:27 arthchan2003
66  * Added super-detailed comments ctxt_table.h. Also added dimension to the arrays that stores all context tables.
67  *
68  * Revision 1.1.2.1 2005/07/15 07:48:32 arthchan2003
69  * split the hmm (whmm_t) and context building process (ctxt_table_t) from the the flat_fwd.c
70  *
71  *
72  */
73 
74 /*
75  * \file ctxt_table.h
76  * \brief data structure for building cross word triphones for Sphinx 3.
77  */
78 
79 #ifndef _CTX_TAB_
80 #define _CTX_TAB_
81 
82 #include <s3types.h>
83 #include <prim_type.h>
84 #include <mdef.h>
85 #include <dict.h>
86 
87 
88 #ifdef __cplusplus
89 extern "C" {
90 #endif
91 #if 0
92 /* Fool Emacs. */
93 }
94 #endif
95 
111 typedef struct {
114  int32 n_ssid;
115 } xwdssid_t;
116 
117 
118 #define ctxt_table_left_ctxt_ssid(ct,l,b,r) ((ct)->lcssid[b][r].ssid[ct->lcssid[b][r].cimap[l]])
119 #define ctxt_table_word_int_ssid(ct,wid,wpos) ((ct)->wwssid[wid][wpos])
120 #define ctxt_table_right_ctxt_ssid(ct,l,b,r) ((ct)->rcssid[b][l].ssid[ct->rcssid[b][l].cimap[r]])
121 #define ctxt_table_single_phone_ssid(ct,l,b,r) ((ct)->lrcssid[b][l].ssid[ct->lrcssid[b][l].cimap[r]])
122 
353 typedef struct {
354  xwdssid_t **lcssid;
359  xwdssid_t **rcssid;
364  xwdssid_t **lrcssid;
370  s3ssid_t **wwssid;
374  int32 n_backoff_ci;
375  int32 n_ci, n_word;
376 } ctxt_table_t ;
377 
383  mdef_t *mdef
384  );
385 
390 void ctxt_table_free(ctxt_table_t *ct);
395 void get_rcssid (ctxt_table_t *ct,
396  s3wid_t w,
397  s3ssid_t **ssid,
398  int32 *nssid,
399  dict_t *dict
400  );
401 
405 void get_lcssid (ctxt_table_t *ct,
406  s3wid_t w,
407  s3ssid_t **ssid,
408  int32 *nssid,
409  dict_t *dict
410  );
411 
412 
419  s3wid_t w,
420  dict_t *dict
421  );
422 
429  s3wid_t w,
430  dict_t *dict
431  );
432 
438 int32 ct_get_rc_nssid (ctxt_table_t *ct,
439  s3wid_t w,
440  dict_t *dict
441  );
442 
443 #ifdef __cplusplus
444 }
445 #endif
446 
447 
448 #endif /*_CTX_TAB_*/