sumom****@users*****
sumom****@users*****
2008年 10月 17日 (金) 08:43:25 JST
Index: julius4/libjulius/src/beam.c diff -u julius4/libjulius/src/beam.c:1.8 julius4/libjulius/src/beam.c:1.9 --- julius4/libjulius/src/beam.c:1.8 Thu Feb 21 13:10:05 2008 +++ julius4/libjulius/src/beam.c Fri Oct 17 08:43:25 2008 @@ -42,7 +42,7 @@ * @author Akinobu LEE * @date Tue Feb 22 17:00:45 2005 * - * $Revision: 1.8 $ + * $Revision: 1.9 $ * */ /* @@ -1713,24 +1713,31 @@ } if (r->lmtype == LM_DFA && r->lmvar == LM_DFA_WORD) { - /* all words can appear at start */ - for (i=0;i<wchmm->winfo->num;i++) { - if (wchmm->hmminfo->multipath) { - node = wchmm->wordbegin[i]; - } else { - node = wchmm->offset[i][0]; - } - if (node_exist_token(d, d->tn, node, d->bos.wid) != TOKENID_UNDEFINED) continue; - newid = create_token(d); - new = &(d->tlist[d->tn][newid]); - new->last_tre = &(d->bos); - new->last_lscore = 0.0; - if (wchmm->hmminfo->multipath) { - new->score = 0.0; - } else { - new->score = outprob_style(wchmm, node, d->bos.wid, 0, param); + /* アクティブな文法に属する単語のみ許す */ + /* only words in active grammars are allowed to be an initial words */ + MULTIGRAM *m; + + for(m = r->lm->grammars; m; m = m->next) { + if (m->active) { + for(i = m->word_begin; i < m->word_begin + m->winfo->num; i++) { + if (wchmm->hmminfo->multipath) { + node = wchmm->wordbegin[i]; + } else { + node = wchmm->offset[i][0]; + } + if (node_exist_token(d, d->tn, node, d->bos.wid) != TOKENID_UNDEFINED) continue; + newid = create_token(d); + new = &(d->tlist[d->tn][newid]); + new->last_tre = &(d->bos); + new->last_lscore = 0.0; + if (wchmm->hmminfo->multipath) { + new->score = 0.0; + } else { + new->score = outprob_style(wchmm, node, d->bos.wid, 0, param); + } + node_assign_token(d, node, newid); + } } - node_assign_token(d, node, newid); } } Index: julius4/libjulius/src/multi-gram.c diff -u julius4/libjulius/src/multi-gram.c:1.5 julius4/libjulius/src/multi-gram.c:1.6 --- julius4/libjulius/src/multi-gram.c:1.5 Tue Aug 5 18:47:56 2008 +++ julius4/libjulius/src/multi-gram.c Fri Oct 17 08:43:25 2008 @@ -47,7 +47,7 @@ * @author Akinobu Lee * @date Sat Jun 18 23:45:18 2005 * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * */ /* @@ -688,9 +688,9 @@ } if (m->newbie) m->newbie = FALSE; if (lm->lmvar == LM_DFA_WORD) { - /* just append dictionaty (category ID is bogus here) */ + /* just append dictionaty */ m->word_begin = lm->winfo->num; - if (voca_append(lm->winfo, m->winfo, 0, m->word_begin) == FALSE) { + if (voca_append(lm->winfo, m->winfo, m->id, m->word_begin) == FALSE) { jlog("ERROR: multi-gram: failed to add dictionary #%d to recognition network\n", m->id); /* mark as delete */ m->hook |= MULTIGRAM_DELETE; @@ -722,9 +722,9 @@ } if (m->newbie) m->newbie = FALSE; if (lm->lmvar == LM_DFA_WORD) { - /* just append dictionaty (category ID is bogus here) */ + /* just append dictionaty */ m->word_begin = lm->winfo->num; - if (voca_append(lm->winfo, m->winfo, 0, m->word_begin) == FALSE) { + if (voca_append(lm->winfo, m->winfo, m->id, m->word_begin) == FALSE) { jlog("ERROR: multi-gram: failed to add dictionary #%d to recognition network\n", m->id); /* mark as delete */ m->hook |= MULTIGRAM_DELETE; @@ -762,7 +762,6 @@ #ifdef MDEBUG jlog("STAT: grammar update completed\n"); #endif - } if (lm->global_modified || active_changed) { return (TRUE); @@ -1143,7 +1142,7 @@ offset = m->winfo->num; printf("adding %d words to grammar #%d (%d words)\n", winfo->num, m->id, m->winfo->num); /* append to the grammar */ - if (voca_append(m->winfo, winfo, 0, offset) == FALSE) { + if (voca_append(m->winfo, winfo, m->id, offset) == FALSE) { jlog("ERROR: multi-gram: failed to add words to dict in grammar #%d \"%s\"\n", m->id, m->name); return FALSE; } Index: julius4/libjulius/src/wchmm.c diff -u julius4/libjulius/src/wchmm.c:1.5 julius4/libjulius/src/wchmm.c:1.6 --- julius4/libjulius/src/wchmm.c:1.5 Tue Sep 30 12:58:17 2008 +++ julius4/libjulius/src/wchmm.c Fri Oct 17 08:43:25 2008 @@ -31,7 +31,7 @@ * @author Akinobu Lee * @date Mon Sep 19 23:39:15 2005 * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * */ /* @@ -1652,7 +1652,7 @@ /* 最も長く音素を共有出来る単語を探す */ maxsharelen=0; for (j=0;j<i;j++) { - if (wchmm->category_tree && wchmm->lmvar == LM_DFA_GRAMMAR) { + if (wchmm->category_tree && wchmm->lmtype == LM_DFA) { if (wchmm->winfo->wton[i] != wchmm->winfo->wton[j]) continue; } sharelen = wchmm_check_match(wchmm->winfo, i, j); @@ -1811,7 +1811,7 @@ windex = (WORD_ID *)mymalloc(sizeof(WORD_ID) * wchmm->winfo->num); for(i=0;i<wchmm->winfo->num;i++) windex[i] = i; - if (wchmm->category_tree && wchmm->lmvar == LM_DFA_GRAMMAR) { + if (wchmm->category_tree && wchmm->lmtype == LM_DFA) { /* sort by category -> sort by word ID in each category */ wchmm_sort_idx_by_category(wchmm->winfo, windex, wchmm->winfo->num); @@ -1903,7 +1903,7 @@ ret = wchmm_add_word(wchmm, i, 0, 0, lmconf->enable_iwsp); } else { /* the previous word (last_i) is always the most matched one */ - if (wchmm->category_tree && wchmm->lmvar == LM_DFA_GRAMMAR) { + if (wchmm->category_tree && wchmm->lmtype == LM_DFA) { if (wchmm->winfo->wton[i] != wchmm->winfo->wton[last_i]) { ret = wchmm_add_word(wchmm, i, 0, 0, lmconf->enable_iwsp); } else {