sumom****@users*****
sumom****@users*****
2013年 6月 21日 (金) 14:24:27 JST
Index: julius4/libsent/src/voca/voca_load_htkdict.c diff -u julius4/libsent/src/voca/voca_load_htkdict.c:1.15 julius4/libsent/src/voca/voca_load_htkdict.c:1.16 --- julius4/libsent/src/voca/voca_load_htkdict.c:1.15 Fri Jun 21 02:14:26 2013 +++ julius4/libsent/src/voca/voca_load_htkdict.c Fri Jun 21 14:24:27 2013 @@ -19,7 +19,7 @@ * @author Akinobu LEE * @date Fri Feb 18 19:43:06 2005 * - * $Revision: 1.15 $ + * $Revision: 1.16 $ * */ /* @@ -376,7 +376,7 @@ char *ptmp, *lp = NULL, *p; static char cbuf[MAX_HMMNAME_LEN]; HMM_Logical **tmpwseq; - int len; + int i, len; HMM_Logical *tmplg; boolean pok; int vnum; @@ -512,19 +512,27 @@ *ok_flag = FALSE; return TRUE; } - if (ptmp[1] == '\0') { /* space between ':' and figures */ + if ((ptmp[1] < '0' || ptmp[1] > '9') && ptmp[1] != '.') { /* not figure after ':' */ jlog("Error: voca_load_htkdict: line %d: value after ':' missing, maybe wrong space?\n> %s\n", linenum, bufbak); winfo->errnum++; *ok_flag = FALSE; return TRUE; } + + /* allocate if not yet */ + if (winfo->weight == NULL) { + winfo->weight = (LOGPROB *)mymalloc(sizeof(LOGPROB) * winfo->maxnum); + for (i = 0; i < vnum; i++) { + winfo->weight[i] = 1.0; + } + } winfo->weight[vnum] = atof(&(ptmp[1])); } else{ - winfo->weight[vnum] = 1.0; /* default, same minimization WER */ + if (winfo->weight) + winfo->weight[vnum] = 1.0; /* default, same minimization WER */ } #endif - /* phoneme sequence */ if (hmminfo == NULL) { Index: julius4/libsent/src/voca/voca_load_wordlist.c diff -u julius4/libsent/src/voca/voca_load_wordlist.c:1.11 julius4/libsent/src/voca/voca_load_wordlist.c:1.12 --- julius4/libsent/src/voca/voca_load_wordlist.c:1.11 Fri Jun 21 02:14:26 2013 +++ julius4/libsent/src/voca/voca_load_wordlist.c Fri Jun 21 14:24:27 2013 @@ -13,7 +13,7 @@ * @author Akinobu LEE * @date Sun Jul 22 13:29:32 2007 * - * $Revision: 1.11 $ + * $Revision: 1.12 $ * */ /* @@ -202,7 +202,7 @@ static char cbuf[MAX_HMMNAME_LEN]; static HMM_Logical **tmpwseq = NULL; static int tmpmaxlen; - int len; + int i, len; HMM_Logical *tmplg; boolean pok, first; int vnum; @@ -300,7 +300,7 @@ ptmp = winfo->wname[vnum]; } if (ptmp == NULL) { - jlog("Error: voca_load_htkdict: line %d: corrupted data:\n> %s\n", linenum, bufbak); + jlog("Error: voca_load_wordlist: line %d: corrupted data:\n> %s\n", linenum, bufbak); winfo->errnum++; *ok_flag = FALSE; return TRUE; @@ -310,7 +310,7 @@ #ifdef USE_MBR /* just move pointer to next token */ if ((ptmp = mystrtok_movetonext(NULL, " \t\n")) == NULL) { - jlog("Error: voca_load_htkdict: line %d: corrupted data:\n> %s\n", linenum, bufbak); + jlog("Error: voca_load_wordlist: line %d: corrupted data:\n> %s\n", linenum, bufbak); winfo->errnum++; *ok_flag = FALSE; return TRUE; @@ -324,21 +324,31 @@ /* if ":" not found, it means weight == 1.0 (same minimization WER) */ if ((ptmp = mystrtok(NULL, " \t\n")) == NULL) { - jlog("Error: voca_load_htkdict: line %d: corrupted data:\n> %s\n", linenum, bufbak); + jlog("Error: voca_load_wordlist: line %d: corrupted data:\n> %s\n", linenum, bufbak); winfo->errnum++; *ok_flag = FALSE; return TRUE; } - if (ptmp[1] == '\0') { /* space between ':' and figures */ - jlog("Error: voca_load_htkdict: line %d: value after ':' missing, maybe wrong space?\n> %s\n", linenum, bufbak); + if ((ptmp[1] < '0' || ptmp[1] > '9') && ptmp[1] != '.') { /* not figure after ':' */ + jlog("Error: voca_load_wordlist: line %d: value after ':' missing, maybe wrong space?\n> %s\n", linenum, bufbak); winfo->errnum++; *ok_flag = FALSE; return TRUE; } + + /* allocate if not yet */ + if (winfo->weight == NULL) { + winfo->weight = (LOGPROB *)mymalloc(sizeof(LOGPROB) * winfo->maxnum); + for (i = 0; i < vnum; i++) { + winfo->weight[i] = 1.0; + } + } + winfo->weight[vnum] = atof(&(ptmp[1])); } else{ - winfo->weight[vnum] = 1.0; /* default, same minimization WER */ + if (winfo->weight) + winfo->weight[vnum] = 1.0; /* default, same minimization WER */ } #endif @@ -362,7 +372,7 @@ /* insert head phone at beginning of word */ if (contextphone) { if (strlen(contextphone) >= MAX_HMMNAME_LEN) { - jlog("Error: voca_load_htkdict: line %d: too long phone name: %s\n", linenum, contextphone); + jlog("Error: voca_load_wordlist: line %d: too long phone name: %s\n", linenum, contextphone); winfo->errnum++; *ok_flag = FALSE; return TRUE; @@ -378,7 +388,7 @@ return TRUE; } if (strlen(lp) >= MAX_HMMNAME_LEN) { - jlog("Error: voca_load_htkdict: line %d: too long phone name: %s\n", linenum, lp); + jlog("Error: voca_load_wordlist: line %d: too long phone name: %s\n", linenum, lp); winfo->errnum++; *ok_flag = FALSE; return TRUE; @@ -391,7 +401,7 @@ if (lp != NULL) { /* token exist */ if (strlen(lp) >= MAX_HMMNAME_LEN) { - jlog("Error: voca_load_htkdict: line %d: too long phone name: %s\n", linenum, lp); + jlog("Error: voca_load_wordlist: line %d: too long phone name: %s\n", linenum, lp); winfo->errnum++; *ok_flag = FALSE; return TRUE; @@ -401,7 +411,7 @@ /* no more token, insert tail phone at end of word */ if (contextphone) { if (strlen(contextphone) >= MAX_HMMNAME_LEN) { - jlog("Error: voca_load_htkdict: line %d: too long phone name: %s\n", linenum, contextphone); + jlog("Error: voca_load_wordlist: line %d: too long phone name: %s\n", linenum, contextphone); winfo->errnum++; *ok_flag = FALSE; return TRUE; Index: julius4/libsent/src/voca/voca_malloc.c diff -u julius4/libsent/src/voca/voca_malloc.c:1.10 julius4/libsent/src/voca/voca_malloc.c:1.11 --- julius4/libsent/src/voca/voca_malloc.c:1.10 Fri Jun 21 02:14:26 2013 +++ julius4/libsent/src/voca/voca_malloc.c Fri Jun 21 14:24:27 2013 @@ -12,7 +12,7 @@ * @author Akinobu LEE * @date Fri Feb 18 21:33:29 2005 * - * $Revision: 1.10 $ + * $Revision: 1.11 $ * */ /* @@ -109,11 +109,6 @@ winfo->maxwlen = 0; winfo->errnum = 0; winfo->errph_root = NULL; - -#ifdef USE_MBR - winfo->weight = (LOGPROB *)mymalloc(sizeof(LOGPROB)*n); -#endif - } /** @@ -145,7 +140,8 @@ winfo->is_transparent = (boolean *)myrealloc(winfo->is_transparent, sizeof(boolean)*n); #ifdef USE_MBR - winfo->weight = (LOGPROB *)myrealloc(winfo->weight, sizeof(LOGPROB)*n); + if (winfo->weight) + winfo->weight = (LOGPROB *)myrealloc(winfo->weight, sizeof(LOGPROB)*n); #endif winfo->maxnum = n;