srch_word_switch_tree.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 /* srch_word_switch_tree.c
39  * HISTORY
40  *
41  * $Log$
42  * Revision 1.1 2006/04/05 20:27:30 dhdfu
43  * A Great Reorganzation of header files and executables
44  *
45  * Revision 1.3 2006/02/23 16:52:56 arthchan2003
46  * Merged from branch: SPHINX3_5_2_RCI_IRII_BRANCH: this fills in the code for doing tree propagation. However, rescoring is still being used. The code is working. However, it takes up huge amount of memory and I consider this as not elegant. It also shows that straight forward implementation of tree copies search doesn't work even in these days.
47  *
48  *
49  * Revision 1.1.4.5 2006/01/16 20:15:37 arthchan2003
50  * 1, removed the unlinksilences part, 2, added 2nd-stage interface, but now commented.
51  *
52  * Revision 1.1.4.4 2005/07/07 02:41:55 arthchan2003
53  * 1, Added an experimental version of tree expansion interface it the code, it does tree expansion without history pruning. Currently disabled because it used to much memory space srch_word_switch_tree.[ch]. 2, Remove -lminsearch segments of code, it proves to be unnecessary. 3, Remove the rescoring interface. In this search, WST_rescoring is actually not doing rescoring, it is rather a segment of code which collect all active word end together and input it into the viterbi history.
54  *
55  * Revision 1.1.4.3 2005/07/04 07:24:15 arthchan2003
56  * Added some comments
57  *
58  * Revision 1.1.4.2 2005/06/27 05:37:05 arthchan2003
59  * Incorporated several fixes to the search. 1, If a tree is empty, it will be removed and put back to the pool of tree, so number of trees will not be always increasing. 2, In the previous search, the answer is always "STOP P I T G S B U R G H </s>"and filler words never occurred in the search. The reason is very simple, fillers was not properly propagated in the search at all <**exculamation**> This version fixed this problem. The current search will give <sil> P I T T S B U R G H </sil> </s> to me. This I think it looks much better now.
60  *
61  * Revision 1.1.4.1 2005/06/24 21:13:52 arthchan2003
62  * 1, Turn on mode 5 again, 2, fixed srch_WST_end, 3, Add empty function implementations of add_lm and delete_lm in mode 5. This will make srch.c checking happy.
63  *
64  * Revision 1.2 2005/06/22 08:00:09 arthchan2003
65  * Completed all doxygen documentation on file description for libs3decoder/libutil/libs3audio and programs.
66  *
67  * Revision 1.1 2005/06/22 02:45:52 arthchan2003
68  * Log. Implementation of word-switching tree. Currently only work for a
69  * very small test case and it's deliberately fend-off from users. Detail
70  * omitted.
71  *
72  * Revision 1.9 2005/05/11 06:10:39 archan
73  * Code for lattice and back track pointer table dumping is now wrapped in reg_result_dump. The function is shared across mode 4 and mode 5. Possibly later for mode 3 and mode 6 as well.
74  *
75  * Revision 1.8 2005/05/03 04:09:10 archan
76  * Implemented the heart of word copy search. For every ci-phone, every word end, a tree will be allocated to preserve its pathscore. This is different from 3.5 or below, only the best score for a particular ci-phone, regardless of the word-ends will be preserved at every frame. The graph propagation will not collect unused word tree at this point. srch_WST_propagate_wd_lv2 is also as the most stupid in the century. But well, after all, everything needs a start. I will then really get the results from the search and see how it looks.
77  *
78  * 17-Mar-2005 A. Chan (archan@cs.cmu.edu) at Carnegie Mellon University
79  * Started. Word condition tree search. Aka lexical tree copies.
80  */
81 
82 #ifndef _SRCH_WST_H_
83 #define _SRCH_WST_H_
84 
89 #include "hash_table.h"
90 #include "glist.h"
91 #include "s3types.h"
92 #include "kb.h"
93 #include "lm.h"
94 #include "lextree.h"
95 #include "fast_algo_struct.h"
96 
110 #ifdef __cplusplus
111 extern "C" {
112 #endif
113 #if 0
114 /* Fool Emacs. */
115 }
116 #endif
117 
118 typedef struct {
135  hash_table_t *active_word;
146  int32 isLMLA;
152 
153 
154 extern struct srch_funcs_s srch_WST_funcs;
155 
156 
157 int srch_WST_init(kb_t *kb,
158  void* srch_struct
159  );
160 
161 int srch_WST_uninit(void* srch_struct);
162 int srch_WST_begin(void* srch_struct);
163 int srch_WST_end(void* srch_struct);
164 int srch_WST_decode(void* srch_struct);
165 
166 int srch_WST_set_lm(void* srch_struct, const char* lmname);
167 int srch_WST_add_lm(void* srch, lm_t *lm, const char *lmname);
168 int srch_WST_delete_lm(void* srch, const char *lmname);
169 
170 int srch_WST_gmm_compute_lv2(void* srch_struct, float32 *feat, int32 time);
171 int srch_WST_hmm_compute_lv1(void* srch_struct);
172 int srch_WST_hmm_compute_lv2(void* srch_struct, int32 frmno);
173 int srch_WST_eval_beams_lv1 (void* srch_struct);
174 int srch_WST_eval_beams_lv2 (void* srch_struct);
175 int srch_WST_propagate_graph_ph_lv1(void* srch_struct);
176 int srch_WST_propagate_graph_wd_lv1(void* srch_struct);
177 
178 int srch_WST_propagate_graph_ph_lv2(void* srch_struct, int32 frmno);
179 
183 int srch_WST_propagate_graph_wd_lv2(void* srch_struct, int32 frmno);
184 
185 
186 int srch_WST_compute_heuristic(void *srch, int32 win_efv);
187 int srch_WST_frame_windup(void *srch_struct,int32 frmno);
188 int srch_WST_shift_one_cache_frame(void *srch,int32 win_efv);
189 int srch_WST_select_active_gmm(void *srch);
190 
191 glist_t srch_WST_gen_hyp(void* srch_struct
192  );
193 
194 int srch_WST_dump_vithist(void* srch_struct
195  );
196 
197 int srch_WST_bestpath_impl(void * srch_struct
198  );
199 
200 #ifdef __cplusplus
201 }
202 #endif
203 
204 #endif /* _SRCH_WST_H_ */
int srch_WST_end(void *srch_struct)
File that implement various structure for fast algorithms. fast_algo_struct implement beam_t...
Definition: lextree.h:233
Definition: srch.h:613
Structure for multiple LM, provide operations for addition/deletion/read Structure for multiple...
lextree_t * curroottree
Definition: srch_word_switch_tree.h:121
Definition: kb.h:156
int srch_WST_hmm_compute_lv2(void *srch_struct, int32 frmno)
int srch_WST_delete_lm(void *srch, const char *lmname)
lextree_t * curfillertree
Definition: srch_word_switch_tree.h:126
glist_t empty_tree_idx_stack
Definition: srch_word_switch_tree.h:137
int srch_WST_init(kb_t *kb, void *srch_struct)
int32 n_static_lextree
Definition: srch_word_switch_tree.h:119
int srch_WST_uninit(void *srch_struct)
int srch_WST_set_lm(void *srch_struct, const char *lmname)
histprune_t * histprune
Definition: srch_word_switch_tree.h:148
int srch_WST_add_lm(void *srch, lm_t *lm, const char *lmname)
lextree_t ** expandtree
Definition: srch_word_switch_tree.h:123
int srch_WST_begin(void *srch_struct)
int srch_WST_eval_beams_lv1(void *srch_struct)
int32 no_active_word
Definition: srch_word_switch_tree.h:143
Data structure of lexical tree.
int srch_WST_propagate_graph_wd_lv1(void *srch_struct)
Size definition of semantically units. Common for both s3 and s3.X decoder.
Structure containing various histogram pruning parameters and internal storage All in integers...
Definition: fast_algo_struct.h:190
int srch_WST_propagate_graph_wd_lv2(void *srch_struct, int32 frmno)
Definition: srch_word_switch_tree.h:118
The global wrapper structure for all variables in 3.X search. We may want to use it for sphinx 3...
int32 isLMLA
Definition: srch_word_switch_tree.h:146
int srch_WST_propagate_graph_ph_lv1(void *srch_struct)
int srch_WST_compute_heuristic(void *srch, int32 win_efv)
int srch_WST_decode(void *srch_struct)
glist_t srch_WST_gen_hyp(void *srch_struct)
int srch_WST_dump_vithist(void *srch_struct)
int srch_WST_hmm_compute_lv1(void *srch_struct)
int srch_WST_frame_windup(void *srch_struct, int32 frmno)
lextree_t ** roottree
Definition: srch_word_switch_tree.h:132
lextree_t ** expandfillertree
Definition: srch_word_switch_tree.h:127
int srch_WST_gmm_compute_lv2(void *srch_struct, float32 *feat, int32 time)
The language model. All unigrams are read into memory on initialization. Bigrams and trigrams read in...
int srch_WST_shift_one_cache_frame(void *srch, int32 win_efv)
lmset_t * lmset
Definition: srch_word_switch_tree.h:145
int srch_WST_bestpath_impl(void *srch_struct)
hash_table_t * active_word
Definition: srch_word_switch_tree.h:135
int srch_WST_select_active_gmm(void *srch)
struct srch_funcs_s srch_WST_funcs
Language model.
int srch_WST_eval_beams_lv2(void *srch_struct)
int srch_WST_propagate_graph_ph_lv2(void *srch_struct, int32 frmno)