search.h
Go to the documentation of this file.
1 /* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */
2 /* ====================================================================
3  * Copyright (c) 1995-2002 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  * search.h -- All exported search-related functions and data structures.
39  *
40  * **********************************************
41  * CMU ARPA Speech Project
42  *
43  * Copyright (c) 1996 Carnegie Mellon University.
44  * ALL RIGHTS RESERVED.
45  * **********************************************
46  *
47  * HISTORY
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.7 2006/02/28 22:29:39 egouvea
54  * Redefined hyp_t as "search_hyp_t" rather than "struct search_hyp_t".
55  *
56  * Revision 1.6 2006/02/24 12:43:18 arthchan2003
57  * Fixed typedef issue of hyp_t and srch_hyp_t.
58  *
59  * Revision 1.5 2006/02/23 15:12:09 arthchan2003
60  * Merged from branch SPHINX3_5_2_RCI_IRII_BRANCH: Introduced srch_hyp_t and conf_srch_hyp_t. The former unifies the usage of multiple hyp_t in the past. The latter is only used in confidence estimation.
61  *
62  * Revision 1.4.4.5 2006/01/16 18:28:19 arthchan2003
63  * 1, Fixed dox-doc, 2, Added confidence scores parameter in search.h. Also change names of parameters.
64  *
65  * Revision 1.4.4.4 2005/11/17 06:30:37 arthchan2003
66  * Remove senscale from srch_hyp_t (Also see changes in vithist.[ch]). Added some preliminary structure for confidence score estimation.
67  *
68  * Revision 1.4.4.3 2005/07/26 02:19:20 arthchan2003
69  * Comment out hyp_t, change name of wid in srch_hyp_t to id.
70  *
71  * Revision 1.4.4.2 2005/07/24 19:34:46 arthchan2003
72  * Removed search_hyp_t, used srch_hyp_t instead
73  *
74  * Revision 1.4.4.1 2005/06/27 05:37:58 arthchan2003
75  * Fixes to make the search of fsg in place (NOT WORKING NOW) in Makefile.am.
76  *
77  * Revision 1.4 2005/06/21 23:34:39 arthchan2003
78  * Remove all dag functions. Eventually I may just want to delete the whole file as well.
79  *
80  * Revision 1.2 2005/06/03 05:46:19 archan
81  * Refactoring across dag/astar/decode_anytopo. Code is not fully tested.
82  * There are several changes I have done to refactor the code across
83  * dag/astar/decode_anyptop. A new library called dag.c is now created
84  * to include all routines that are shared by the three applications that
85  * required graph operations.
86  * 1, dag_link is now shared between dag and decode_anytopo. Unfortunately, astar was using a slightly different version of dag_link. At this point, I could only rename astar'dag_link to be astar_dag_link.
87  * 2, dag_update_link is shared by both dag and decode_anytopo.
88  * 3, hyp_free is now shared by misc.c, dag and decode_anytopo
89  * 4, filler_word will not exist anymore, dict_filler_word was used instead.
90  * 5, dag_param_read were shared by both dag and astar.
91  * 6, dag_destroy are now shared by dag/astar/decode_anytopo. Though for some reasons, even the function was not called properly, it is still compiled in linux. There must be something wrong at this point.
92  * 7, dag_bestpath and dag_backtrack are now shared by dag and decode_anytopo. One important thing to notice here is that decode_anytopo's version of the two functions actually multiply the LM score or filler penalty by the language weight. At this point, s3_dag is always using lwf=1.
93  * 8, dag_chk_linkscr is shared by dag and decode_anytopo.
94  * 9, decode_anytopo nows supports another three options -maxedge, -maxlmop and -maxlpf. Their usage is similar to what one could find dag.
95  *
96  * Notice that the code of the best path search in dag and that of 2-nd
97  * stage of decode_anytopo could still have some differences. It could
98  * be the subtle difference of handling of the option -fudge. I am yet
99  * to know what the true cause is.
100  *
101  * Some other small changes include
102  * -removal of startwid and finishwid asstatic variables in s3_dag.c. dict.c now hide these two variables.
103  *
104  * There are functions I want to merge but I couldn't and it will be
105  * important to say the reasons.
106  * i, dag_remove_filler_nodes. The version in dag and decode_anytopo
107  * work slightly differently. The decode_anytopo's one attached a dummy
108  * predecessor after removal of the filler nodes.
109  * ii, dag_search.(s3dag_dag_search and s3flat_fwd_dag_search) The handling of fudge is differetn. Also, decode_anytopo's one now depend on variable lattice.
110  * iii, dag_load, (s3dag_dag_load and s3astar_dag_load) astar and dag seems to work in a slightly different, one required removal of arcs, one required bypass the arcs. Don't understand them yet.
111  * iv, dag_dump, it depends on the variable lattice.
112  *
113  * Revision 1.1.1.1 2005/03/24 15:24:00 archan
114  * I found Evandro's suggestion is quite right after yelling at him 2 days later. So I decide to check this in again without any binaries. (I have done make distcheck. ) . Again, this is a candidate for s3.6 and I believe I need to work out 4-5 intermediate steps before I can complete the first prototype. That's why I keep local copies.
115  *
116  * Revision 1.3 2004/12/06 10:52:01 arthchan2003
117  * Enable doxygen documentation in libs3decoder
118  *
119  * Revision 1.2 2004/08/31 08:43:47 arthchan2003
120  * Fixing _cpluscplus directive
121  *
122  * Revision 1.1 2004/08/09 00:17:12 arthchan2003
123  * Incorporating s3.0 align, at this point, there are still some small problems in align but they don't hurt. For example, the score doesn't match with s3.0 and the output will have problem if files are piped to /dev/null/. I think we can go for it.
124  *
125  * Revision 1.2 2002/12/03 23:02:44 egouvea
126  * Updated slow decoder with current working version.
127  * Added copyright notice to Makefiles, *.c and *.h files.
128  * Updated some of the documentation.
129  *
130  * Revision 1.1.1.1 2002/12/03 20:20:46 robust
131  * Import of s3decode.
132  *
133  *
134  * 07-Nov-96 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University
135  * Added onlynodes argument to dag_dump().
136  *
137  * 12-Sep-96 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University
138  * Changed fwd_sen_active to flag active senones instead of building a list
139  * of them.
140  *
141  * 24-Jun-96 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University
142  * Added dag_search().
143  *
144  * 20-Jan-96 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University
145  * Added function fwd_sen_active() to obtain list of active senones in
146  * current frame.
147  *
148  * 04-Dec-95 M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University
149  * Started.
150  */
151 
152 
153 #ifndef _LIBFBS_SEARCH_H_
154 #define _LIBFBS_SEARCH_H_
155 
160 #include "s3types.h"
161 
162 #ifdef __cplusplus
163 extern "C" {
164 #endif
165 #if 0
166 } /* Fool Emacs into not indenting things. */
167 #endif
168 
172 typedef struct srch_hyp_s {
173  char *word;
175  int32 id;
179  int32 vhid;
183  int32 type;
187  int32 ascr;
188  int32 lscr;
189  int32 pscr;
190  int32 cscr;
192  int32 fsg_state;
194  struct srch_hyp_s *next;
198 } srch_hyp_t;
199 
205 
210 typedef struct conf_srch_hyp {
212  float32 lmtype;
213  float32 l1, l2, l3;
214  int32 matchtype;
215  int compound;
216  struct conf_srch_hyp *next;
218 
219 
224 typedef struct seg_hyp_line {
225  char seq[1024];
227  int32 cscore ;
228  float32 lmtype;
229  int32 wordno;
230  int32 nfr;
231  int32 ascr;
232  int32 lscr;
235 
236 #if 0
237 { /* Stop indent from complaining */
238 #endif
239 #ifdef __cplusplus
240 }
241 #endif
242 
243 #endif
srch_hyp_t sh
Definition: search.h:211
a hypothesis structure
a hypothesis structure that stores the confidence scores. Mainly used in confidence.c
int32 pscr
Definition: search.h:189
int16 s3frmid_t
Definition: s3types.h:172
Definition: search.h:210
int32 cscr
Definition: search.h:190
char * word
Definition: search.h:173
int32 lscr
Definition: search.h:188
int32 sent_end_cscore
Definition: search.h:226
Definition: search.h:172
struct srch_hyp_s srch_hyp_t
int32 type
Definition: search.h:183
int32 id
Definition: search.h:175
int32 fsg_state
Definition: search.h:192
int32 cscore
Definition: search.h:227
float32 lmtype
Definition: search.h:212
int32 nfr
Definition: search.h:230
float32 l1
Definition: search.h:213
Definition: search.h:224
conf_srch_hyp_t * wordlist
Definition: search.h:233
struct srch_hyp_s * next
Definition: search.h:194
Size definition of semantically units. Common for both s3 and s3.X decoder.
char seq[1024]
Definition: search.h:225
int32 ascr
Definition: search.h:187
float32 l3
Definition: search.h:213
int32 matchtype
Definition: search.h:214
s3frmid_t ef
Definition: search.h:186
int32 wordno
Definition: search.h:229
float32 l2
Definition: search.h:213
int compound
Definition: search.h:215
struct conf_srch_hyp * next
Definition: search.h:216
int32 ascr
Definition: search.h:231
int32 vhid
Definition: search.h:179
srch_hyp_t hyp_t
Definition: search.h:204
struct seg_hyp_line seg_hyp_line_t
float32 lmtype
Definition: search.h:228
int32 lscr
Definition: search.h:232
struct conf_srch_hyp conf_srch_hyp_t
s3frmid_t sf
Definition: search.h:185