libsent/src/dfa/dfa_util.c

Go to the documentation of this file.
00001 
00018 /*
00019  * Copyright (c) 1991-2007 Kawahara Lab., Kyoto University
00020  * Copyright (c) 2000-2005 Shikano Lab., Nara Institute of Science and Technology
00021  * Copyright (c) 2005-2007 Julius project team, Nagoya Institute of Technology
00022  * All rights reserved
00023  */
00024 
00025 #include <sent/stddefs.h>
00026 #include <sent/dfa.h>
00027 
00034 void
00035 print_dfa_info(FILE *fp, DFA_INFO *dinfo)
00036 {
00037   if (fp == NULL) return;
00038   fprintf(fp, " DFA grammar info:\n");
00039   fprintf(fp, "      %d nodes, %d arcs, %d terminal(category) symbols\n",
00040          dinfo->state_num, dinfo->arc_num, dinfo->term_num);
00041   fprintf(fp, "      size of category-pair matrix is %d bytes\n",
00042          sizeof(unsigned char) * dinfo->term_num * dinfo->term_num / 8);
00043 }
00044 
00051 void
00052 print_dfa_cp(FILE *fp, DFA_INFO *dinfo)
00053 {
00054   int i,j;
00055   int t;
00056 
00057   if (fp == NULL) return;
00058   fprintf(fp, "---------- terminal(category)-pair matrix ----------\n");
00059   /* horizontal ruler */
00060   fprintf(fp, "    ");
00061   for (j=0;j<dinfo->term_num;j++) {
00062     if (j > 0 && (j % 10) == 0) {
00063       t = j / 10;
00064       fprintf(fp, "%1d", t);
00065     } else {
00066       fprintf(fp, " ");
00067     }
00068   }
00069   fprintf(fp, "\n    ");
00070   for (j=0;j<dinfo->term_num;j++) {
00071     fprintf(fp, "%1d", j % 10);
00072   }
00073   fprintf(fp, "\n");
00074   
00075   fprintf(fp, "bgn ");
00076   for (j=0;j<dinfo->term_num;j++) {
00077     fprintf(fp, (dfa_cp_begin(dinfo, j) == TRUE) ? "o" : " ");
00078   }
00079   fprintf(fp, "\n");
00080   fprintf(fp, "end ");
00081   for (j=0;j<dinfo->term_num;j++) {
00082     fprintf(fp, (dfa_cp_end(dinfo, j) == TRUE) ? "o" : " ");
00083   }
00084   fprintf(fp, "\n");
00085   for (i=0;i<dinfo->term_num;i++) {
00086     fprintf(fp, "%3d ",i);
00087     for (j=0;j<dinfo->term_num;j++) {
00088       fprintf(fp, (dfa_cp(dinfo, i, j) == TRUE) ? "o" : " ");
00089     }
00090     fprintf(fp, "\n");
00091   }
00092 }

Generated on Tue Dec 18 15:59:54 2007 for Julius by  doxygen 1.5.4