confidence.h

Go to the documentation of this file.
00001 /* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */
00002 /* ====================================================================
00003  * Copyright (c) 1995-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 /* confidence.h: Calculate confidence scores from word lattices using
00038  * posterior word probabilities and backoff.
00039  *
00040  * Copyright (c) 2004 Carnegie Mellon University.
00041  * 
00042  * Author: Rong Zhang <rongz@cs.cmu.edu>
00043  *
00044  * Arthur Chan has significantly changed these routines when incorporating to Sphinx 3.x
00045  *
00046  * $Log$
00047  * Revision 1.1  2006/04/05  20:27:30  dhdfu
00048  * A Great Reorganzation of header files and executables
00049  * 
00050  * Revision 1.2  2006/02/21 18:31:09  arthchan2003
00051  * Merge confidence.c confidence.h and Makefile.am into the trunk.
00052  *
00053  * Revision 1.1.2.1  2006/01/16 18:38:25  arthchan2003
00054  * Adding Rong's confidence routine.  Compare to Rong's routine, this routine used Sphinx3's njmerical routines and make the chances of backward-forward scores inconsistency to be lower.
00055  *
00056  */
00057 
00058 #ifndef __CONFIDENCE_H__
00059 #define __CONFIDENCE_H__
00060 
00061 
00062 #include <stdio.h>
00063 
00064 #include <logmath.h>
00065 #include "dict.h"
00066 #include "lm.h"
00067 #include "fillpen.h"
00068 #include "s3types.h"
00069 #include "search.h"
00070 
00071 #define CONFIDENCE_MAX_INT 2147483640
00072 #define CONFIDENCE_MIN_INT -2147483640
00073 #define CONFIDENCE_FAILURE 0
00074 #define CONFIDENCE_SUCCESS 1
00075 #define MAGIC_CONFIDENCE_CONSTANT 39.5
00076 #define MIN_LOG -690810000
00077 
00078 
00079 #ifdef __cplusplus
00080 extern "C" {
00081 #endif
00082 #if 0
00083 /* Fool Emacs. */
00084 }
00085 #endif
00086 
00092 typedef struct ca_dagnode_type {
00093     char word[64]; 
00094     int wid; 
00095     int seqid; 
00096     int sf; 
00097     int fef; 
00098     int lef;  
00099     int reachable; 
00100     int visited; 
00101     int fanin; 
00102     int fanout; 
00103     int hscore; 
00104     int pscore; 
00105     int lscore; 
00106     int cscore; 
00107     struct ca_daglink_type *succlist;
00108     struct ca_daglink_type *predlist;
00109     struct ca_dagnode_type *alloc_next;
00110 } ca_dagnode;
00111 
00112 typedef struct ca_daglink_type {
00113     ca_dagnode *from; 
00114     ca_dagnode *to; 
00115     int ascore;  
00116     int alpha_beta; 
00118     struct ca_daglink_type *next;
00119 } ca_daglink;
00120 
00121 typedef struct ca_dag_type {
00122     ca_dagnode *nodelist;
00123     ca_dagnode **seqidtonode;
00124     ca_daglink entry;
00125     ca_daglink exit;
00126     int nfrm;
00127     int nnode;
00128     int nedge;
00129     logmath_t *logmath;
00130 } ca_dag;
00131 
00132 
00137 S3DECODER_EXPORT
00138 int32 confidence_word_posterior(char* dagfile,  
00139                                 seg_hyp_line_t *seg_hyp_line,  
00140                                 char* uttid,  
00141                                 lm_t *lm,   
00142                                 dict_t *dict,  
00143                                 fillpen_t *fpen 
00144     );
00145 
00146 
00147 #if 0 /* Not public */
00148 
00151 int ca_dag_load_lattice(char *filename, 
00152                         ca_dag *word_lattice,  
00153                         lm_t *lm,    
00154                         dict_t *dict, 
00155                         fillpen_t* fillpen 
00156     );
00157 
00161 int alpha_beta(ca_dag *word_lattice, 
00162                lm_t* lm,  
00163                dict_t* dict 
00164     );
00165 
00166 /*
00167   Given a seg_hyp_line, i.e. one hypothesis with time
00168   information. Compute the posterior word probability score using the
00169   lattice. 
00170 */
00171 int pwp(seg_hyp_line_t *seg_hyp_line,  
00172         ca_dag *word_lattice  
00173     );
00174 
00178 int ca_dag_free_lattice(ca_dag *word_lattice);
00179 
00180 #endif
00181 
00185 S3DECODER_EXPORT
00186 int compute_lmtype(seg_hyp_line_t *seg_hyp_line,  
00187                    lm_t* lm,
00188                    dict_t* dict
00189     );
00190 
00191 S3DECODER_EXPORT
00192 int compute_combined_lmtype(seg_hyp_line_t *seg_hyp_line);
00193 
00194 #ifdef __cplusplus
00195 }
00196 #endif
00197 
00198 
00199 #endif /* __CONFIDENCE_H__ */
00200 

Generated on 7 Mar 2010 by  doxygen 1.6.1