libsent/src/hmminfo/cdhmm.c

Go to the documentation of this file.
00001 
00018 /*
00019  * Copyright (c) 1991-2007 Kawahara Lab., Kyoto University
00020  * Copyright (c) 2000-2005 Shikano Lab., Nara Institute of Science and Technology
00021  * Copyright (c) 2005-2007 Julius project team, Nagoya Institute of Technology
00022  * All rights reserved
00023  */
00024 
00025 #include <sent/stddefs.h>
00026 #include <sent/htk_hmm.h>
00027 
00045 void
00046 add_right_context(char name[], char *rc)
00047 {
00048   char *p;
00049   int i;
00050 
00051   if ((p = strchr(name, HMM_RC_DLIM_C)) != NULL) {
00052     p++;
00053     *p = '\0';
00054   } else {
00055     strcat(name, HMM_RC_DLIM);
00056   }
00057   i = strlen(name);
00058   center_name(rc, &(name[i]));
00059 }
00060 
00072 void
00073 add_left_context(char name[], char *lc)
00074 {
00075   char *p;
00076   static char buf[MAX_HMMNAME_LEN];
00077 
00078   if ((p = strchr(name, HMM_LC_DLIM_C)) != NULL) {
00079     p++;
00080   } else {
00081     p = name;
00082   }
00083   center_name(lc, buf);
00084   strcat(buf, HMM_LC_DLIM);
00085   strcat(buf, p);
00086   strcpy(name, buf);
00087 }
00088 
00089 static char gbuf[MAX_HMMNAME_LEN]; 
00090 
00106 HMM_Logical *
00107 get_right_context_HMM(HMM_Logical *base, char *rc_name, HTK_HMM_INFO *hmminfo)
00108 {
00109   strcpy(gbuf, base->name);
00110   add_right_context(gbuf, rc_name);
00111   return(htk_hmmdata_lookup_logical(hmminfo, gbuf));
00112 }
00113 
00128 HMM_Logical *
00129 get_left_context_HMM(HMM_Logical *base, char *lc_name, HTK_HMM_INFO *hmminfo)
00130 {
00131   strcpy(gbuf, base->name);
00132   add_left_context(gbuf, lc_name);
00133   return(htk_hmmdata_lookup_logical(hmminfo, gbuf));
00134 }
00135   
00144 char *
00145 center_name(char *hmmname, char *buf)
00146 {
00147   char *p, *s, *d;
00148 
00149   p = hmmname;
00150   d = buf;
00151 
00152   /* move next to '-' */
00153   while (*p != HMM_LC_DLIM_C && *p != '\0') p++;
00154   if (*p == '\0') s = hmmname;
00155   else s = ++p;
00156 
00157   while (*s != HMM_RC_DLIM_C && *s != '\0') {
00158     *d = *s;
00159     d++;
00160     s++;
00161   }
00162   *d = '\0';
00163 
00164   return (buf);
00165 }
00166 
00175 char *
00176 leftcenter_name(char *hmmname, char *buf)
00177 {
00178   char *p;
00179   /* strip off "+..." */
00180   strcpy(buf, hmmname);
00181   if ((p = strchr(buf, HMM_RC_DLIM_C)) != NULL) {
00182     *p = '\0';
00183   }
00184   return(buf);
00185 }
00186 
00187 /* return right+center(base) phone name */
00188 /* modify content of buf[] */
00197 char *
00198 rightcenter_name(char *hmmname, char *buf)
00199 {
00200   char *p;
00201   /* strip off "...-" */
00202   if ((p = strchr(hmmname, HMM_LC_DLIM_C)) != NULL && *(p+1) != '\0') {
00203     strcpy(buf, p+1);
00204   } else {
00205     strcpy(buf, hmmname);
00206   }
00207   return(buf);
00208 }

Generated on Tue Dec 18 15:59:55 2007 for Julius by  doxygen 1.5.4