kb.h

Go to the documentation of this file.
00001 /* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */
00002 /* ====================================================================
00003  * Copyright (c) 1999-2004 Carnegie Mellon University.  All rights
00004  * reserved.
00005  *
00006  * Redistribution and use in source and binary forms, with or without
00007  * modification, are permitted provided that the following conditions
00008  * are met:
00009  *
00010  * 1. Redistributions of source code must retain the above copyright
00011  *    notice, this list of conditions and the following disclaimer. 
00012  *
00013  * 2. Redistributions in binary form must reproduce the above copyright
00014  *    notice, this list of conditions and the following disclaimer in
00015  *    the documentation and/or other materials provided with the
00016  *    distribution.
00017  *
00018  * This work was supported in part by funding from the Defense Advanced 
00019  * Research Projects Agency and the National Science Foundation of the 
00020  * United States of America, and the CMU Sphinx Speech Consortium.
00021  *
00022  * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND 
00023  * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
00024  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00025  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY
00026  * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00027  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
00028  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
00029  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
00030  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
00031  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
00032  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00033  *
00034  * ====================================================================
00035  *
00036  */
00037 /*
00038  * kb.h -- Knowledge bases, search parameters, and auxiliary structures for decoding
00039  * 
00040  * **********************************************
00041  * CMU ARPA Speech Project
00042  *
00043  * Copyright (c) 1999 Carnegie Mellon University.
00044  * ALL RIGHTS RESERVED.
00045  * **********************************************
00046  * 
00047  * HISTORY
00048  * $Log$
00049  * Revision 1.1  2006/04/05  20:27:30  dhdfu
00050  * A Great Reorganzation of header files and executables
00051  * 
00052  * Revision 1.18  2006/02/23 05:44:59  arthchan2003
00053  * Merged from the branch SPHINX3_5_2_RCI_IRII_BRANCH.
00054  * 1, Added temp_init_vithistory, this will choose to initialize the correct viterbi history given the mode.
00055  * 2, Moved most of the code in kb_setmllr to adaptor.c
00056  *
00057  * Revision 1.17.4.2  2005/09/18 01:21:18  arthchan2003
00058  * 1, Add a latticehist_t into kb_t, use a temporary method to allow polymorphism of initialization of vithist_t and latticehist_t. 2, remove the logic kb_set_mllr and put it to adapt_set_mllr
00059  *
00060  * Revision 1.17.4.1  2005/07/03 23:00:58  arthchan2003
00061  * Free stat_t, histprune_t and srch_t correctly.
00062  *
00063  * Revision 1.17  2005/06/21 23:21:58  arthchan2003
00064  * Log. This is a big refactoring for kb.c and it is worthwhile to give
00065  * words on why and how things were done.  There were generally a problem
00066  * that the kb structure itself is too flat.  That makes it has to
00067  * maintained many structure that could be maintained by smaller
00068  * structures.  For example, the count of A and the array of A should
00069  * well be put into the same structure to increase readability and
00070  * modularity. One can explain why histprune_t, pl_t, stat_t and
00071  * adapt_am_t were introduced with that line of reasoning.
00072  *
00073  * In srch_t, polymorphism of implementation is also one important
00074  * element in separting all graph related members from kb_t to srch_t.
00075  * One could probably implement the polymorphism as an interface of kb
00076  * but it is not trivial from the semantic meaning of kb.  That is
00077  * probably why srch_t is introduced as the gateway of search interfaces.
00078  *
00079  * Another phenonemon one could see in the code was bad interaction
00080  * between modules. This is quite serious in two areas: logging and
00081  * checking. The current policy is unless something required cross
00082  * checking two structures, they would be done internally inside a module
00083  * initialization.
00084  *
00085  * Finally, kb_setlm is now removed and is replaced by ld_set_lm (by
00086  * users) or srch_set_lm (by developers). I think this is quite
00087  * reasonable.
00088  *
00089  * Revision 1.10  2005/06/19 19:41:23  archan
00090  * Sphinx3 to s3.generic: Added multiple regression class for single stream MLLR. Enabled MLLR for livepretend and decode.
00091  *
00092  * Revision 1.9  2005/05/11 06:10:38  archan
00093  * 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.
00094  *
00095  * Revision 1.8  2005/04/25 23:53:35  archan
00096  * 1, Some minor modification of vithist_t, vithist_rescore can now support optional LM rescoring, vithist also has its own reporting routine. A new argument -lmrescore is also added in decode and livepretend.  This can switch on and off the rescoring procedure. 2, I am reaching the final difficulty of mode 5 implementation.  That is, to implement an algorithm which dynamically decide which tree copies should be entered.  However, stuffs like score propagation in the leave nodes and non-leaves nodes are already done. 3, As briefly mentioned in 2, implementation of rescoring , which used to happened at leave nodes are now separated. The current implementation is not the most clever one. Wish I have time to change it before check-in to the canonical.
00097  *
00098  * Revision 1.7  2005/04/20 03:36:18  archan
00099  * Remove setlm from kb entirely, refactor it to search implementations, do the corresponding change for the changes in ascr and pl
00100  *
00101  * Revision 1.6  2005/03/30 01:22:47  archan
00102  * Fixed mistakes in last updates. Add
00103  *
00104  * 
00105  * 14-Jun-2004  Yitao Sun (yitao@cs.cmu.edu) at Carnegie Mellon University
00106  *              Modified struct kb_t to save the last hypothesis.
00107  *
00108  * 07-Jul-1999  M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University
00109  *              Added kb_t.ci_active.
00110  * 
00111  * 02-Jun-1999  M K Ravishankar (rkm@cs.cmu.edu) at Carnegie Mellon University
00112  *              Started.
00113  */
00114 
00115 
00116 #ifndef _S3_KB_H_
00117 #define _S3_KB_H_
00118 
00119 #include <stdio.h>
00120 
00121 #include <s3types.h>
00122 #include <cmd_ln.h>
00123 #include <fe.h>
00124 #include "kbcore.h"
00125 #include "ascr.h"
00126 #include "fast_algo_struct.h"
00127 #include "stat.h"
00128 #include "adaptor.h"
00129 
00135 #ifdef __cplusplus
00136 extern "C" {
00137 #endif
00138 #if 0
00139 } /* Fool Emacs into not indenting things. */
00140 #endif
00141 
00142 
00143 /*
00144  * ARCHAN :20040229. Starting from s3.4, we accept users to specify mutliple LMs
00145  * using -lmctlfile. To avoid potential overhead caused by rebuilding the trees
00146  * at every sentence. We allocate all lexical trees in the intialization. If we
00147  * assume the number of words to be less than 64k and the number of LMs is smaller
00148  * than 100. This memory loss should be fine.  Later: We should allow users to specify
00149  * the memory address mode by their own discretion.
00150  */
00151 
00152 
00153 /* The wrapper structure of all operation in the Sphinx 3.X decoder. 
00154  *
00155  */
00156 typedef struct {
00162     kbcore_t *kbcore;       
00165     fe_t *fe;             
00166     mfcc_t **mfcc;        
00167     float32 ***feat;      
00170     ascr_t *ascr;                 
00171     beam_t *beam;                 
00172     fast_gmm_t *fastgmm;    
00173     pl_t *pl;               
00176     adapt_am_t * adapt_am;  
00178     stat_t *stat;           
00181     FILE *matchfp;          
00182     FILE *matchsegfp;       
00183     FILE *hmmdumpfp;        
00185     /* The only variable I intend to make it be alone in the whole
00186        structure. It has its own uniqueness. (dhuggins: I have no idea
00187        what that means)  */
00188     int32 op_mode; 
00189     char *uttid;   
00190     char *uttfile;   
00193     void *srch;  
00194 } kb_t;
00195 
00196 
00198 S3DECODER_EXPORT
00199 void kb_init(kb_t *kb, 
00200              cmd_ln_t *config 
00201     );
00202 
00203   
00205 S3DECODER_EXPORT
00206 void kb_free (kb_t *kb
00207     );  /* RAH 4.16.01 */
00208   
00210 S3DECODER_EXPORT
00211 void kb_setmllr(const char* mllrname, 
00212                 const char* cb2mllrname, 
00213                 kb_t *kb
00214     );    /* ARCHAN 20040724 */
00215 
00217 S3DECODER_EXPORT
00218 void kb_set_uttid(const char *uttid, 
00219                   const char *uttfile, 
00220                   kb_t *kb
00221     );   /* ARCHAN 20041111 */
00222 
00223 
00224 #if 0
00225 { /* Stop indent from complaining */
00226 #endif
00227 #ifdef __cplusplus
00228 }
00229 #endif
00230 
00231 #endif

Generated on 7 Mar 2010 by  doxygen 1.6.1