void SquadronClass::InitPilots (void)
	{
	int		i,last_commander;

	// Start with full load of pilots
	last_commander = PILOTS_PER_SQUADRON/3;
	for (i=0; i<PILOTS_PER_SQUADRON; i++)
		{
// 2000-11-17 MODIFIED BY S.G. NEED TO PASS THE 'airExperience' OF THE TEAM SO I CAN USE IT AS A BASE
//		GetPilotData(i)->ResetStats();
		GetPilotData(i)->ResetStats(TeamInfo[GetOwner()]->airExperience);
		if (!i)								// First slot is Colonel.
			GetPilotData(i)->pilot_id = GetAvailablePilot(TeamInfo[GetOwner()]->firstColonel,TeamInfo[GetOwner()]->firstCommander, GetOwner());
		else if (i < last_commander)		// First 1/3 are commanders
			GetPilotData(i)->pilot_id = GetAvailablePilot(TeamInfo[GetOwner()]->firstCommander,TeamInfo[GetOwner()]->firstWingman, GetOwner());
		else								// otherwise normal wingmen
			GetPilotData(i)->pilot_id = GetAvailablePilot(TeamInfo[GetOwner()]->firstWingman,TeamInfo[GetOwner()]->lastWingman, GetOwner());
		}
	// Special code to select certain squadron leaders.
	if (GetNameId() == 36)
		{
		pilot_data[0].pilot_id = 1;
		pilot_data[0].pilot_skill_and_rating = 0x44;
		}
	else if (GetNameId() == 80)
		pilot_data[0].pilot_id = 2;
	else if (GetNameId() == 35)
		pilot_data[0].pilot_id = 3;
	}
Example #2
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);
   }
}
Example #3
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)) {
Example #4
0
/* Initialise: perform global initialisations */
static void Initialise(void)
{
   int i,j,ndx;
   float x;
   LMInfo *li;
   Boolean inLM;
   LabId *wid,lab;
   NameId *na,nid;
   Boolean isPipe;

   nulClass = GetLabId(nulName,TRUE);

   /* normalise weights */
   for (x=0.0, i=1; i<nLModel; i++)
      x += lmInfo[i].weight;
   lmInfo[0].weight = 1.0-x;

   /* load all models */
   for (li=lmInfo, i=0; i<nLModel; i++, li++) {
      if (trace&T_TOP)
	 printf("Loading language model from %s\n",li->fn);
      li->lm = LoadLangModel(li->fn,NULL,1.0,LMP_LOG|LMP_COUNT,&permHeap);
      if (li->lm->probType==LMP_COUNT)
	 RebuildLM(li->lm,cutOff,wdThresh,LMP_LOG);
      AttachAccessInfo(li->lm);
   }

   if (trace&T_TOP) {
      printf("Using language model(s): \n");
      for (li=lmInfo,i=0; i<nLModel; i++,li++)
	 printf("  %d-gram %s, weight %.2f\n",li->lm->nSize,li->fn,li->weight);
   }
   if (numTests==0) {
      numTests=1; testInfo[0] = lmInfo[0].lm->nSize;
   }

   /* load or create word list */
   if (wlistFN!=NULL) {
      /* load word list from file */
      CreateWordList(wlistFN,&wList,nWords+10);
      nWords = wList.used;
      for (wid=wList.id, i=0; i<nWords; i++,wid++) /* assign lookup indices */
	 (*wid)->aux = (Ptr) (i+1);
   } else {
      /* derive word list from LMs */
      for (nWords=0,li=lmInfo, i=0; i<nLModel; i++, li++)
      {
 	 /* Obtain class-LM word list in a different way */
	 if (li->lm->classLM)
	 {
	   na = li->lm->classBM;

	   for (j=0; j<li->lm->classW; j++)
	   {
	     lab = GetLabId(na[j+1]->name, TRUE);
	     if (lab->aux==NULL)
	       lab->aux = (Ptr) (++nWords);
	   }
	 }
	 else
	 {
	   na = li->lm->binMap;

	   for (j=0; j<li->lm->vocSize; j++)
	   {
	     lab = GetLabId(na[j+1]->name,TRUE);
	     if (lab->aux==NULL)
	       lab->aux = (Ptr) (++nWords);
	   }
	 }
      }
      CreateWordList(NULL,&wList,nWords+10);
      for (li=lmInfo, i=0; i<nLModel; i++, li++) {
	/* Obtain class-LM word list in a different way */
	if (li->lm->classLM)
	{
	  na = li->lm->classBM;

	  for (j=0; j<li->lm->classW; j++)
	  {
	    lab = GetLabId(na[j+1]->name,TRUE);
	    ndx = ((int) lab->aux) - 1;
	    wList.id[ndx] = lab;
	  }
	}
	else
	{
	  na = li->lm->binMap;

	  for (j=0; j<li->lm->vocSize; j++)
	  {
	    lab = GetLabId(na[j+1]->name,TRUE);
	    ndx = ((int) lab->aux) - 1;
	    wList.id[ndx] = lab;
	  }
	}

      }
      wList.used = nWords;
   }
   if (trace&T_TOP) {
      printf("Found %d unique words in %d model(s)\n",nWords,nLModel);
      fflush(stdout);
   }
   if (unkId->aux==NULL && !skipOOV) {
      HError(16620,"LPlex: OOV class symbol %s not in word list",unkId->name);
   }
   if (sstId->aux==NULL) {
      HError(16620,"LPlex: sentence start symbol %s not in word list",sstId->name);
   }
   if (senId->aux==NULL) {
      HError(16620,"LPlex: sentence end symbol %s not in word list",senId->name);
   }

   /* create lookup table */
   l2nId = (NameId **) New(&permHeap,nLModel*sizeof(NameId *));
   /* create LabId -> NameId lookup arrays (one per LM) */
   for (li=lmInfo, i=0; i<nLModel; i++, li++, na++) {
      na = (NameId *) New(&permHeap,(nWords+2)*sizeof(NameId));
      for (wid = wList.id, j=0; j<nWords; j++, wid++) {
	if (li->lm->classLM)
	{
	  nid = na[(int) ((*wid)->aux)] = GetNameId(li->lm->classH, (*wid)->name, FALSE);
	}
	else
	{
	  nid = na[(int) ((*wid)->aux)] = GetNameId(li->lm->htab, (*wid)->name, FALSE);
	}
#ifdef SANITY
	 if (nid==NULL)
	    HError(-16625,"Unable to find word %s in model %s\n",(*wid)->name,li->fn);
#endif
      }
      l2nId[i] = na;
   }

   /* ensure words present at least in one model */
   for (wid = wList.id, j=0; j<nWords; j++, wid++) {
      for (inLM=FALSE,i=0; i<nLModel; i++, li++)
	 if (l2nId[i][(int) ((*wid)->aux)]!=NULL)
	    inLM = TRUE;
      if (!inLM)
	 HError(16625,"Unable to find word %s in any model\n",(*wid)->name);
   }

   /* create equivalence class lookup array */
   eqId = (LabId *) New(&permHeap,(nWords+NumEquiv()+2)*sizeof(NameId));
   for (wid = wList.id, i=0; i<nWords; i++, wid++) {
      eqId[(int) ((*wid)->aux)] = NULL;
   }

   /* link equivalence classes */
   LinkEquiv();

   /* open output stream */
   if (outStreamFN != NULL)
     if ((outStream = FOpen(outStreamFN,NoOFilter,&isPipe)) == NULL)
        HError(16610,"Initialise: unable to open output file %s",outStreamFN);

}