Ejemplo n.º 1
0
/* ReplaceUnigrams: replace unigrams in lm with ones from fn */
void ReplaceUnigrams(char *fn, BackOffLM *lm)
{
   float prob;
   SMEntry *se;
   NameId wdid;
   int ndx,nItem;
   FLEntry *root;
   char buf[MAXSTRLEN];
   Source src;

   nItem = 0;
   root = &lm->root;
   if(InitSource(fn,&src,NoFilter)<SUCCESS)
      HError(16910,"ReplaceUnigrams: Can't open file %s", fn);
   do {
      if (!ReadFloat(&src,&prob,1,FALSE)) break;
      if (!ReadRawString(&src,buf)) break; /* or ReadString if HTK escaped */
      if ((wdid = GetNameId(lm->htab,buf,FALSE))==NULL) {
         printf("skipping '%s'\n", buf);
         continue;
      }
      ndx = LM_INDEX(wdid); se = root->sea+ndx-1;
      if (se->ndx!=ndx && (se=FindSE(root->sea,0,root->nse,ndx))==NULL) {
         printf("ignoring '%s'\n", buf);
         continue;
      }
      se->prob = exp(prob*LN10);
      nItem++;
   } while(SkipLine(&src));
   CloseSource(&src);
   if (trace&T_TOP) {
      printf("Replaced %d unigrams from %s\n",nItem,uniFn); fflush(stdout);
   }
}
Ejemplo n.º 2
0
   nParm = GetConfig("LPCALC", TRUE, cParm, MAXGLOBS);

   if (nParm>0){

#ifndef HTK_TRANSCRIBER

      if (GetConfInt(cParm,nParm, "TRACE",&i))    trace = i;

#endif

      if (GetConfStr(cParm,nParm, "STARTWORD",s)) strcpy(sstStr,s);

   }

   sstId = GetLabId(sstStr,TRUE);

}



/* EXPORT->InitBuildInfo: initialise build parameters */

void InitBuildInfo(BuildInfo *bi)

{

   int i, j;    /* Temporary values */

   char s[256]; /* Temporary string */



   bi->nSize = 0;

   bi->ftab  = NULL;

   bi->saveFmt  = DEF_SAVEFMT;

   bi->ptype    = DEF_LMPTYPE;

   bi->uniFloor = DEF_UNIFLOOR;

   bi->kRange   = DEF_KRANGE;

   bi->dctype   = DEF_DCTYPE;

   for (i=1; i<=LM_NSIZE; i++) 

      bi->cutOff[i] = DEF_CUTOFF;

   bi->wmap = NULL;

   bi->inSet = NULL;

   if (GetConfInt(cParm,nParm, "UNIFLOOR",&i)) bi->uniFloor = i;

   if (GetConfInt(cParm,nParm, "KRANGE",&i))   bi->kRange = i;

   if (GetConfStr(cParm,nParm, "DCTYPE",s)) {