Exemplo 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);
   }
}
Exemplo 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)) {
Exemplo n.º 3
0
Arquivo: type1.c Projeto: chrr/libECP
doubleArray
calcChi(Type1 *t1, double *U_L, ECP *U,
	double *rAC, const double dAC, double *rBC, const double dBC, 
	const int la, const int shella, const int offseta, const int shifta, doubleArray uspA,  
	const int lb, const int shellb, const int offsetb, const int shiftb, doubleArray uspB) {
  const int N_a = t1->contraction[shella];
  const double *zs_a = t1->a + offseta;
  const double *cs_a = t1->d + offseta;
  const int N_b = t1->contraction[shellb];
  const double *zs_b = t1->a + offsetb;
  const double *cs_b = t1->d + offsetb;
  int pa, pb;
  double ca, za, cb, zb, factor;
  double P[3], S[3];
  const int lab = la+lb;
  int ax, ay, az, bx, by, bz;
  int i, j, p, l, m, lmax, lx, ly, lz;
  double *rsph, *PM = t1->poly2sph;
  int *ijkIndex = t1->ijkIndex;
  const int ijkDim = t1->ijkDim;
  const int tmDim = L_DIM(t1->tmDim);
  doubleArray Q, chi = doubleArray_new(2, C_DIM(la), C_DIM(lb));
  int incQ, inc = chi.dim[2];
  
  for(pa=0; pa<N_a; pa++) {
    za = zs_a[pa];
    ca = cs_a[pa]; 
    /* nth derivative: extra factor of zeta^n */
    for(p=0; p<shifta; p++)
      ca *= za;
    
    for(pb=0; pb<N_b; pb++) {
      zb = zs_b[pb];
      cb = cs_b[pb];
      for(p=0; p<shiftb; p++)
	cb *= zb;

      /* note: use of rAC,rBC introduces change in sign */
      for (p=0; p<3; p++) 
	P[p] = 2.0*(za*rAC[p] + zb*rBC[p]);
      sphericalCoordinates(P, S);
      rsph = realSphericalHarmonics(lab, S[1], S[2], t1->fac, t1->dfac);
            
      /* bessel weight 's' corresponds to S[0] */
      Q = calcQ(t1, U_L, U, S[0], lab, dAC, ca, za, shifta, dBC, cb, zb, shiftb);
      if (NULL==Q.array) {
	doubleArray_free(chi);
	free(rsph);
	return chi;
      }
      incQ = Q.dim[2];

      /* construct cartesian components */
      // FIXME - ??? for(alpha=0; alpha<=la; alpha++) {
      //               for(c1=0; c1<IJK_DIM(alpha); c1++) { ...
      for(ax=0; ax<=la; ax++) {
	for(ay=0; ay<=la-ax; ay++) {
	  for(az=0; az<=la-ax-ay; az++) {
	    i = ijkIndex[ax*ijkDim*ijkDim + ay*ijkDim + az];
	    for(bx=0; bx<=lb; bx++) {
	      lx = ax + bx;
	      for(by=0; by<=lb-bx; by++) {
		ly = ay + by;
		for(bz=0; bz<=lb-bx-by; bz++) {
		  j = ijkIndex[bx*ijkDim*ijkDim + by*ijkDim + bz];
		  lz = az + bz;
		  lmax = lx + ly + lz;

 		  /* final index for P matrix */
		  p = ijkIndex[lx*ijkDim*ijkDim + ly*ijkDim + lz];

		  for(l=lmax; l>=0; l-=2) {
		    factor = 0.0;
		    for(m=0; m<2*l+1; m++) {
		      factor += rsph[LM_INDEX(l,m)] * PM[p*tmDim+LM_INDEX(l,m)];
		    }
		    chi.array[i*inc+j] += factor * Q.array[lmax*incQ+l];
		  }
		  //printf(" libecp type1:  %d,%d  %d,%d  chi[%d,%d,%d][%d,%d,%d] = %.12f\n", la, lb, pa, pb, ax, ay, az, bx, by, bz, chi.array[i*inc+j]);
		}
	      }
	    }
	  }
	}
      }
      doubleArray_free(Q);
      free(rsph);
    }
  }

  return chi;
}