libsent/src/dfa/mkterminfo.c

説明を見る。
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/dfa.h>
00026 #include <sent/vocabulary.h>
00027 
00028 /* construct table: terminal(category) ID -> word list */
00029 
00037 void
00038 make_terminfo(TERM_INFO *tinfo, DFA_INFO *dinfo, WORD_INFO *winfo)
00039 {
00040   int i,w,t;
00041   int tnum;
00042 
00043   /* set terminal number */
00044   tnum = tinfo->term_num = dinfo->term_num;
00045   /* allocate memory for the list of word num */
00046   tinfo->wnum = (int *)mymalloc(sizeof(int) * tnum);
00047   /* count number of belonging words for each category */
00048   for(i=0;i<tnum;i++) tinfo->wnum[i]=0;
00049   for(w=0;w<winfo->num;w++) {
00050     tinfo->wnum[winfo->wton[w]]++;
00051   }
00052   /* allocate memory for the list body */
00053   tinfo->tw = (WORD_ID **)mymalloc(sizeof(WORD_ID *) * tnum);
00054   for(i=0;i<tnum;i++) {
00055     tinfo->tw[i] = (WORD_ID *)mymalloc(sizeof(WORD_ID) * tinfo->wnum[i]);
00056   }
00057   /* store the word to each corresponding list */
00058   for(i=0;i<tnum;i++) tinfo->wnum[i]=0;
00059   for(w=0;w<winfo->num;w++) {
00060     t = winfo->wton[w];
00061     tinfo->tw[t][tinfo->wnum[t]] = w;
00062     tinfo->wnum[t]++;
00063   }
00064 
00065 }
00066 
00075 void
00076 terminfo_append(TERM_INFO *dst, TERM_INFO *src, int coffset, int woffset)
00077 {
00078   int t, new_termnum;
00079   int i, j;
00080 
00081   new_termnum = coffset + src->term_num;
00082   if (dst->tw == NULL) {
00083     dst->tw = (WORD_ID **)mymalloc(sizeof(WORD_ID *) * new_termnum);
00084     dst->wnum = (int *)mymalloc(sizeof(int) * new_termnum);
00085   } else {
00086     dst->tw = (WORD_ID **)myrealloc(dst->tw, sizeof(WORD_ID *) * new_termnum);
00087     dst->wnum = (int *)myrealloc(dst->wnum, sizeof(int) * new_termnum);
00088   }
00089   for(i=0;i<src->term_num;i++) {
00090     t = i + coffset;
00091     dst->wnum[t] = src->wnum[i];
00092     dst->tw[t] = (WORD_ID *)mymalloc(sizeof(WORD_ID) * src->wnum[i]);
00093     for(j=0;j<src->wnum[i];j++) {
00094       dst->tw[t][j] = src->tw[i][j] + woffset;
00095     }
00096   }
00097   dst->term_num = new_termnum;
00098 }

Juliusに対してTue Dec 26 16:19:28 2006に生成されました。  doxygen 1.5.0