libsent/src/voca/voca_util.c

Go to the documentation of this file.
00001 
00017 /*
00018  * Copyright (c) 1991-2006 Kawahara Lab., Kyoto University
00019  * Copyright (c) 2000-2005 Shikano Lab., Nara Institute of Science and Technology
00020  * Copyright (c) 2005-2006 Julius project team, Nagoya Institute of Technology
00021  * All rights reserved
00022  */
00023 
00024 #include <sent/stddefs.h>
00025 #include <sent/vocabulary.h>
00026 
00032 void
00033 print_voca_info(WORD_INFO *winfo)
00034 {
00035   int i,j;
00036   long models, states;
00037   int trnum;
00038   HMM_Logical *lg;
00039 
00040   models = 0;
00041   states = 0;
00042   trnum = 0;
00043   for (i=0;i<winfo->num;i++) {
00044     models += winfo->wlen[i];
00045     for (j=0;j<winfo->wlen[i];j++) {
00046       lg = winfo->wseq[i][j];
00047       states += hmm_logical_state_num(lg) - 2;
00048     }
00049     if (winfo->is_transparent[i]) trnum++;
00050   }
00051 
00052   j_printf("Dictionary Info:\n");
00053   /*j_printf("        vocabulary size  = %d words, %d models, %d states\n", winfo->num, models, states);*/
00054   j_printf("        vocabulary size  = %d words, %d models\n", winfo->num, models);
00055   j_printf("        average word len = %.1f models, %.1f states\n", (float)models/(float)winfo->num, (float)states/(float)winfo->num);
00056   j_printf("       maximum state num = %d nodes per word\n", winfo->maxwn);
00057   j_printf("       transparent words = ");
00058   if (trnum > 0) {
00059     j_printf("%d words\n", trnum);
00060   } else {
00061     j_printf("not exist\n");
00062   }
00063 #ifdef CLASS_NGRAM
00064   j_printf("       words under class = ");
00065   if (winfo->cwnum > 0) {
00066     j_printf("%d words\n", winfo->cwnum);
00067   } else {
00068     j_printf("not exist\n");
00069   }    
00070 #endif
00071 }
00072          
00079 void
00080 put_voca(WORD_INFO *winfo, WORD_ID wid)
00081 {
00082   int i;
00083   HMM_Logical *lg;
00084   
00085   j_printf("%d: \"%s", wid, winfo->wname[wid]);
00086 #ifdef CLASS_NGRAM
00087   j_printf(" @%f", winfo->cprob[wid]);
00088 #endif
00089   if (winfo->is_transparent[wid]) {
00090     j_printf(" {%s}", winfo->woutput[wid]);
00091   } else {
00092     j_printf(" [%s]", winfo->woutput[wid]);
00093   }
00094   for(i=0;i<winfo->wlen[wid];i++) {
00095     lg = winfo->wseq[wid][i];
00096     j_printf(" %s", lg->name);
00097     if (lg->is_pseudo) {
00098       j_printf("(pseudo)");
00099     } else {
00100       j_printf("(%s)", lg->body.defined->name);
00101     }
00102   }
00103   j_printf("\"\n");
00104 }
00105 
00112 void
00113 put_voca_err(WORD_INFO *winfo, WORD_ID wid)
00114 {
00115   int i;
00116   HMM_Logical *lg;
00117   
00118   j_printerr("id%d: %s", wid, winfo->wname[wid]);
00119 #ifdef CLASS_NGRAM
00120   j_printerr(" @%f", winfo->cprob[wid]);
00121 #endif
00122   if (winfo->is_transparent) {
00123     j_printerr(" {%s}", winfo->woutput[wid]);
00124   } else {
00125     j_printerr(" [%s]", winfo->woutput[wid]);
00126   }
00127   for(i=0;i<winfo->wlen[wid];i++) {
00128     lg = winfo->wseq[wid][i];
00129     j_printerr(" %s", lg->name);
00130     if (lg->is_pseudo) {
00131       j_printerr("(pseudo)");
00132     } else {
00133       j_printerr("(%s)", lg->body.defined->name);
00134     }
00135   }
00136   j_printerr("\n");
00137 }

Generated on Tue Dec 26 16:16:34 2006 for Julius by  doxygen 1.5.0