sumom****@users*****
sumom****@users*****
2009年 7月 4日 (土) 23:11:43 JST
Index: julius4/libjulius/src/instance.c diff -u julius4/libjulius/src/instance.c:1.3 julius4/libjulius/src/instance.c:1.4 --- julius4/libjulius/src/instance.c:1.3 Thu Sep 25 14:00:06 2008 +++ julius4/libjulius/src/instance.c Sat Jul 4 23:11:42 2009 @@ -12,7 +12,7 @@ * @author Akinobu Lee * @date Sun Oct 28 18:06:20 2007 * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * */ /* @@ -299,15 +299,7 @@ { /* not free jconf, am, lm here */ /* free part of StackDecode work area */ -#ifdef CONFIDENVE_MEASURE -#ifdef CM_MULTIPLE_ALPHA - free(process->pass2.cmsumlist); -#endif -#ifdef CM_NBEST; - free(process->pass2.sentcm); - free(process->pass2.wordcm); -#endif -#endif + wchmm_fbs_free(process); /* free wchmm */ if (process->wchmm) wchmm_free(process->wchmm); /* free backtrellis */ Index: julius4/libjulius/src/m_fusion.c diff -u julius4/libjulius/src/m_fusion.c:1.13 julius4/libjulius/src/m_fusion.c:1.14 --- julius4/libjulius/src/m_fusion.c:1.13 Tue Feb 10 17:15:48 2009 +++ julius4/libjulius/src/m_fusion.c Sat Jul 4 23:11:42 2009 @@ -20,7 +20,7 @@ * @author Akinobu Lee * @date Thu May 12 13:31:47 2005 * - * $Revision: 1.13 $ + * $Revision: 1.14 $ * */ /* @@ -1115,6 +1115,9 @@ p->backtrellis = (BACKTRELLIS *)mymalloc(sizeof(BACKTRELLIS)); bt_init(p->backtrellis); + /* prepare work area for 2nd pass */ + wchmm_fbs_prepare(p); + jlog("STAT: SR%02d %s composed\n", sconf->id, sconf->name); if (sconf->sw.start_inactive) { Index: julius4/libjulius/src/ngram_decode.c diff -u julius4/libjulius/src/ngram_decode.c:1.3 julius4/libjulius/src/ngram_decode.c:1.4 --- julius4/libjulius/src/ngram_decode.c:1.3 Wed Feb 13 17:45:27 2008 +++ julius4/libjulius/src/ngram_decode.c Sat Jul 4 23:11:42 2009 @@ -35,7 +35,7 @@ * @author Akinobu Lee * @date Fri Jul 8 14:57:51 2005 * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * */ /* @@ -198,10 +198,9 @@ int w_old = WORD_INVALID; #endif int num; - WORD_ID cnword[MAX_N]; ///< Last two non-transparent words - WORD_ID cnwordrev[MAX_N]; ///< Last two non-transparent words int cnnum; ///< Num of found non-transparent words (<=2) int last_trans; ///< Num of skipped transparent words + StackDecode *dwrk; BACKTRELLIS *bt; WORD_INFO *winfo; @@ -215,6 +214,7 @@ lm_weight2 = r->config->lmp.lm_weight2; lm_penalty2 = r->config->lmp.lm_penalty2; lm_penalty_trans = r->config->lmp.lm_penalty_trans; + dwrk = &(r->pass2); /* set word contexts to cnword[] from 1 considering transparent words */ if (ngram) { @@ -222,7 +222,7 @@ last_trans = 0; for(i=hypo->seqnum-1;i>=0;i--) { if (! winfo->is_transparent[hypo->seq[i]]) { - cnword[cnnum+1] = hypo->seq[i]; + dwrk->cnword[cnnum+1] = hypo->seq[i]; cnnum++; if (cnnum >= ngram->n - 1) break; } else { @@ -231,14 +231,14 @@ } if (ngram->dir == DIR_RL) { for(i=0;i<cnnum;i++) { - cnwordrev[cnnum-1-i] = cnword[i+1]; + dwrk->cnwordrev[cnnum-1-i] = dwrk->cnword[i+1]; } } /* use ngram id */ if (ngram->dir == DIR_RL) { - for(i=0;i<cnnum;i++) cnwordrev[i] = winfo->wton[cnwordrev[i]]; + for(i=0;i<cnnum;i++) dwrk->cnwordrev[i] = winfo->wton[dwrk->cnwordrev[i]]; } else { - for(i=0;i<cnnum;i++) cnword[i+1] = winfo->wton[cnword[i+1]]; + for(i=0;i<cnnum;i++) dwrk->cnword[i+1] = winfo->wton[dwrk->cnword[i+1]]; } } @@ -264,11 +264,11 @@ /* compute N-gram probability */ if (ngram->dir == DIR_RL) { /* just compute N-gram prob of the word candidate */ - cnwordrev[cnnum] = winfo->wton[w]; - rawscore = ngram_prob(ngram, cnnum + 1, cnwordrev); + dwrk->cnwordrev[cnnum] = winfo->wton[w]; + rawscore = ngram_prob(ngram, cnnum + 1, dwrk->cnwordrev); } else { - cnword[0] = winfo->wton[w]; - rawscore = ngram_forw2back(ngram, cnword, cnnum + 1); + dwrk->cnword[0] = winfo->wton[w]; + rawscore = ngram_forw2back(ngram, dwrk->cnword, cnnum + 1); } #ifdef CLASS_NGRAM rawscore += winfo->cprob[w]; Index: julius4/libjulius/src/search_bestfirst_main.c diff -u julius4/libjulius/src/search_bestfirst_main.c:1.8 julius4/libjulius/src/search_bestfirst_main.c:1.9 --- julius4/libjulius/src/search_bestfirst_main.c:1.8 Sun Nov 16 21:28:04 2008 +++ julius4/libjulius/src/search_bestfirst_main.c Sat Jul 4 23:11:42 2009 @@ -35,7 +35,7 @@ * @author Akinobu Lee * @date Thu Sep 08 11:51:12 2005 * - * $Revision: 1.8 $ + * $Revision: 1.9 $ * */ /* @@ -2264,4 +2264,94 @@ clear_stocker(dwrk); } +/** + * <JA> + * 第2パス用のワークエリアを確保・初期化する. + * + * ここで確保されるのは認識・パラメータに依らない値のみ. + * + * @param r [i/o] 認識処理インスタンス + * </JA> + * <EN> + * Initialize and allocate work area for 2nd pass. + * + * This function only contains input / parameter dependent initialization. + * + * @param r [in] recognition process instance + * </EN> + */ +void +wchmm_fbs_prepare(RecogProcess *r) +{ + StackDecode *dwrk; + dwrk = &(r->pass2); + + /* N-gram 用ワークエリアを確保 */ + /* malloc work area for N-gram */ + if (r->lmtype == LM_PROB && r->lm->ngram) { + dwrk->cnword = (WORD_ID *)mymalloc(sizeof(WORD_ID) * r->lm->ngram->n); + dwrk->cnwordrev = (WORD_ID *)mymalloc(sizeof(WORD_ID) * r->lm->ngram->n); + } else { + dwrk->cnword = dwrk->cnwordrev = NULL; + } + dwrk->stocker_root = NULL; +#ifdef CONFIDENVE_MEASURE +#ifdef CM_MULTIPLE_ALPHA + dwrk->cmsumlist = NULL; +#endif +#ifdef CM_NBEST; + dwrk->sentcm = NULL; + dwrk->wordcm = NULL; +#endif +#endif +} + +/** + * <JA> + * 第2パス用のワークエリアを解放する. + * + * ここで解放されるのは認識・パラメータに依らない値のみ. + * + * @param r [i/o] 認識処理インスタンス + * </JA> + * <EN> + * Free the work area for 2nd pass. + * + * This function only concerns input / parameter dependent work area. + * + * @param r [in] recognition process instance + * </EN> + */ +void +wchmm_fbs_free(RecogProcess *r) +{ + StackDecode *dwrk; + dwrk = &(r->pass2); + + if (r->lmtype == LM_PROB && r->lm->ngram) { + free(dwrk->cnword); + free(dwrk->cnwordrev); + dwrk->cnword = dwrk->cnwordrev = NULL; + } + +#ifdef CONFIDENVE_MEASURE +#ifdef CM_MULTIPLE_ALPHA + if (dwrk->cmsumlist) { + free(dwrk->cmsumlist); + dwrk->cmsumlist = NULL; + } +#endif +#ifdef CM_NBEST; + if (dwrk->sentcm) { + free(dwrk->sentcm); + dwrk->sentcm = NULL; + } + if (dwrk->wordcm) { + free(dwrk->wordcm); + dwrk->wordcm = NULL; + } +#endif +#endif +} + /* end of file */