Julius 4.2
libsent/src/voca/voca_util.c
説明を見る。
00001 
00018 /*
00019  * Copyright (c) 1991-2011 Kawahara Lab., Kyoto University
00020  * Copyright (c) 2000-2005 Shikano Lab., Nara Institute of Science and Technology
00021  * Copyright (c) 2005-2011 Julius project team, Nagoya Institute of Technology
00022  * All rights reserved
00023  */
00024 
00025 #include <sent/stddefs.h>
00026 #include <sent/vocabulary.h>
00027 
00034 void
00035 print_voca_info(FILE *fp, WORD_INFO *winfo)
00036 {
00037   if (fp == NULL) return;
00038 
00039   fprintf(fp, " Vocabulary Info:\n");
00040   fprintf(fp, "        vocabulary size  = %d words, %d models\n", winfo->num, winfo->totalmodelnum);
00041   fprintf(fp, "        average word len = %.1f models, %.1f states\n", (float)winfo->totalmodelnum/(float)winfo->num, (float)winfo->totalstatenum/(float)winfo->num);
00042   fprintf(fp, "       maximum state num = %d nodes per word\n", winfo->maxwn);
00043   fprintf(fp, "       transparent words = ");
00044   if (winfo->totaltransnum > 0) {
00045     fprintf(fp, "%d words\n", winfo->totaltransnum);
00046   } else {
00047     fprintf(fp, "not exist\n");
00048   }
00049 #ifdef CLASS_NGRAM
00050   fprintf(fp, "       words under class = ");
00051   if (winfo->cwnum > 0) {
00052     fprintf(fp, "%d words\n", winfo->cwnum);
00053   } else {
00054     fprintf(fp, "not exist\n");
00055   }    
00056 #endif
00057 }
00058          
00066 void
00067 put_voca(FILE *fp, WORD_INFO *winfo, WORD_ID wid)
00068 {
00069   int i;
00070   HMM_Logical *lg;
00071 
00072   if (fp == NULL) return;
00073   
00074   fprintf(fp, "%d: \"%s", wid, winfo->wname[wid]);
00075 #ifdef CLASS_NGRAM
00076   fprintf(fp, " @%f", winfo->cprob[wid]);
00077 #endif
00078   if (winfo->is_transparent[wid]) {
00079     fprintf(fp, " {%s}", winfo->woutput[wid]);
00080   } else {
00081     fprintf(fp, " [%s]", winfo->woutput[wid]);
00082   }
00083   for(i=0;i<winfo->wlen[wid];i++) {
00084     lg = winfo->wseq[wid][i];
00085     fprintf(fp, " %s", lg->name);
00086     if (lg->is_pseudo) {
00087       fprintf(fp, "(pseudo)");
00088     } else {
00089       fprintf(fp, "(%s)", lg->body.defined->name);
00090     }
00091   }
00092   fprintf(fp, "\"\n");
00093 }