libsent/src/hmminfo/cdhmm.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/htk_hmm.h>
00026 
00044 void
00045 add_right_context(char name[], char *rc)
00046 {
00047   char *p;
00048   int i;
00049 
00050   if ((p = strchr(name, HMM_RC_DLIM_C)) != NULL) {
00051     p++;
00052     *p = '\0';
00053   } else {
00054     strcat(name, HMM_RC_DLIM);
00055   }
00056   i = strlen(name);
00057   center_name(rc, &(name[i]));
00058 }
00059 
00071 void
00072 add_left_context(char name[], char *lc)
00073 {
00074   char *p;
00075   static char buf[MAX_HMMNAME_LEN];
00076 
00077   if ((p = strchr(name, HMM_LC_DLIM_C)) != NULL) {
00078     p++;
00079   } else {
00080     p = name;
00081   }
00082   center_name(lc, buf);
00083   strcat(buf, HMM_LC_DLIM);
00084   strcat(buf, p);
00085   strcpy(name, buf);
00086 }
00087 
00088 static char gbuf[MAX_HMMNAME_LEN]; 
00089 
00105 HMM_Logical *
00106 get_right_context_HMM(HMM_Logical *base, char *rc_name, HTK_HMM_INFO *hmminfo)
00107 {
00108   strcpy(gbuf, base->name);
00109   add_right_context(gbuf, rc_name);
00110   return(htk_hmmdata_lookup_logical(hmminfo, gbuf));
00111 }
00112 
00127 HMM_Logical *
00128 get_left_context_HMM(HMM_Logical *base, char *lc_name, HTK_HMM_INFO *hmminfo)
00129 {
00130   strcpy(gbuf, base->name);
00131   add_left_context(gbuf, lc_name);
00132   return(htk_hmmdata_lookup_logical(hmminfo, gbuf));
00133 }
00134   
00143 char *
00144 center_name(char *hmmname, char *buf)
00145 {
00146   char *p, *s, *d;
00147 
00148   p = hmmname;
00149   d = buf;
00150 
00151   /* move next to '-' */
00152   while (*p != HMM_LC_DLIM_C && *p != '\0') p++;
00153   if (*p == '\0') s = hmmname;
00154   else s = ++p;
00155 
00156   while (*s != HMM_RC_DLIM_C && *s != '\0') {
00157     *d = *s;
00158     d++;
00159     s++;
00160   }
00161   *d = '\0';
00162 
00163   return (buf);
00164 }
00165 
00174 char *
00175 leftcenter_name(char *hmmname, char *buf)
00176 {
00177   char *p;
00178   /* strip off "+..." */
00179   strcpy(buf, hmmname);
00180   if ((p = strchr(buf, HMM_RC_DLIM_C)) != NULL) {
00181     *p = '\0';
00182   }
00183   return(buf);
00184 }
00185 
00186 /* return right+center(base) phone name */
00187 /* modify content of buf[] */
00196 char *
00197 rightcenter_name(char *hmmname, char *buf)
00198 {
00199   char *p;
00200   /* strip off "...-" */
00201   if ((p = strchr(hmmname, HMM_LC_DLIM_C)) != NULL && *(p+1) != '\0') {
00202     strcpy(buf, p+1);
00203   } else {
00204     strcpy(buf, hmmname);
00205   }
00206   return(buf);
00207 }

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