fsg_lextree.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  *
19  * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND
20  * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY
23  * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  *
31  * ====================================================================
32  *
33  */
34 /*
35  * fsg_lextree.h -- The collection of all the lextrees for the entire FSM.
36  *
37  * **********************************************
38  * CMU ARPA Speech Project
39  *
40  * Copyright (c) 2004 Carnegie Mellon University.
41  * ALL RIGHTS RESERVED.
42  * **********************************************
43  *
44  * HISTORY
45  *
46  * $Log$
47  * Revision 1.1 2006/04/05 20:27:30 dhdfu
48  * A Great Reorganzation of header files and executables
49  *
50  * Revision 1.2 2006/02/23 05:10:18 arthchan2003
51  * Merged from branch SPHINX3_5_2_RCI_IRII_BRANCH: Adaptation of Sphinx 2's FSG search into Sphinx 3
52  *
53  * Revision 1.1.2.4 2005/07/24 01:34:54 arthchan2003
54  * Mode 2 is basically running. Still need to fix function such as resulting and build the correct utterance ID
55  *
56  * Revision 1.1.2.3 2005/07/17 05:44:32 arthchan2003
57  * Added dag_write_header so that DAG header writer could be shared between 3.x and 3.0. However, because the backtrack pointer structure is different in 3.x and 3.0. The DAG writer still can't be shared yet.
58  *
59  * Revision 1.1.2.2 2005/07/13 18:39:47 arthchan2003
60  * (For Fun) Remove the hmm_t hack. Consider each s2 global functions one-by-one and replace them by sphinx 3's macro. There are 8 minor HACKs where functions need to be removed temporarily. Also, there are three major hacks. 1, there are no concept of "phone" in sphinx3 dict_t, there is only ciphone. That is to say we need to build it ourselves. 2, sphinx2 dict_t will be a bunch of left and right context tables. This is currently bypass. 3, the fsg routine is using fsg_hmm_t which is just a duplication of CHAN_T in sphinx2, I will guess using hmm_evaluate should be a good replacement. But I haven't figure it out yet.
61  *
62  * Revision 1.1.2.1 2005/06/27 05:26:29 arthchan2003
63  * Sphinx 2 fsg mainpulation routines. Compiled with faked functions. Currently fended off from users.
64  *
65  * Revision 1.1 2004/07/16 00:57:12 egouvea
66  * Added Ravi's implementation of FSG support.
67  *
68  * Revision 1.3 2004/06/23 20:32:16 rkm
69  * *** empty log message ***
70  *
71  * Revision 1.2 2004/05/27 14:22:57 rkm
72  * FSG cross-word triphones completed (but for single-phone words)
73  *
74  * Revision 1.1.1.1 2004/03/01 14:30:31 rkm
75  *
76  *
77  * Revision 1.1 2004/02/23 15:53:45 rkm
78  * Renamed from fst to fsg
79  *
80  * Revision 1.2 2004/02/19 21:16:54 rkm
81  * Added fsg_search.{c,h}
82  *
83  * Revision 1.1 2004/02/18 15:02:34 rkm
84  * Added fsg_lextree.{c,h}
85  *
86  *
87  * 18-Feb-2004 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon
88  * Started.
89  */
90 
91 
92 #ifndef __S2_FSG_LEXTREE_H__
93 #define __S2_FSG_LEXTREE_H__
94 
95 
96 #include <stdio.h>
97 
98 #include <logmath.h>
99 #include <cmd_ln.h>
100 
101 #include "word_fsg.h"
102 #include "fsg_psubtree.h"
103 #include "hmm.h"
104 #include "dict.h"
105 #include "mdef.h"
106 #include "ctxt_table.h"
107 
108 
109 #ifdef __cplusplus
110 extern "C" {
111 #endif
112 #if 0
113 /* Fool Emacs. */
114 }
115 #endif
116 
117 typedef struct fsg_lextree_s {
118  word_fsg_t *fsg; /* The fsg for which this lextree is built */
119  fsg_pnode_t **root; /* root[s] = lextree representing all transitions
120  out of state s. Note that the "tree" for each
121  state is actually a collection of trees, linked
122  via fsg_pnode_t.sibling (root[s]->sibling) */
123  fsg_pnode_t **alloc_head; /* alloc_head[s] = head of linear list of all
124  pnodes allocated for state s */
125  int32 n_pnode; /* #HMM nodes in search structure */
126 
130 } fsg_lextree_t;
131 
132 /* Access macros */
133 #define fsg_lextree_root(lt,s) ((lt)->root[s])
134 #define fsg_lextree_n_pnode(lt) ((lt)->n_pnode)
135 
136 
137 /*
138  * Create, initialize, and return a new phonetic lextree for the given FSM.
139  */
141  hmm_context_t *ctx,
142  cmd_ln_t *config,
143  logmath_t *logmath);
144 
146 
147 
148 void fsg_lextree_dump (fsg_lextree_t *, FILE *);
149 
150 
153 
154 #ifdef __cplusplus
155 }
156 #endif
157 
158 
159 #endif