예제 #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);
   }
}
예제 #2
0
int CTwain::DropToState(int nS, HWND hwnd)
{
	hwnd = DefWnd(hwnd);
	while (nState > nS) {
		switch (nState) {
			case TRANSFERRING:
				if (!EndXfer()) return FALSE;
				break;
			case TRANSFER_READY:
				if (!CancelXfers()) return FALSE;
				break;
			case SOURCE_ENABLED:
				if (!DisableSource()) return FALSE;
				break;
			case SOURCE_OPEN:
				if (!CloseSource()) return FALSE;
				break;
			case SOURCE_MANAGER_OPEN:
				if (!CloseSourceManager(hwnd)) return FALSE;
				break;
			case SOURCE_MANAGER_LOADED:
				if (!UnloadSourceManager()) return FALSE;
				break;
			default:
				ATLASSERT(FALSE);
		} // switch
	} // while
	return TRUE;
}
예제 #3
0
/* EXPORT ReadLModel: Determine LM type and then read-in */
LModel *ReadLModel(MemHeap *heap,char *fn)
{
   LModel *lm;
   LMType type;
   char buf[MAXSTRLEN+1];
   int i;

   lm=(LModel*)New(heap,sizeof(LModel));
   lm->heap=heap;
   lm->name=CopyString(heap,fn);

   if(InitSource(fn,&source,LangModFilter)<SUCCESS)
      HError(8110,"ReadLModel: Can't open file %s", fn);
   type=boNGram;i=0;
   do {
      if (i++==1000) {
         type=matBigram;
         break;
      }
      GetInLine(buf);
   }
   while (strcmp(buf, "\\data\\")!=0);
   CloseSource(&source);

   lm->type=type;
   switch(type) {
   case boNGram:
      ReadBoNGram(lm,fn);
      break;
   case matBigram:
      ReadMatBigram(lm,fn);
      break;
   }
   return(lm);
}
예제 #4
0
/* ReadBoNGram: read and store WSJ/DP format ngram */
static void ReadBoNGram(LModel *lm,char *fn)
{
   NGramLM *nglm;
   int i,j,k,counts[NSIZE+1];
   Boolean ngBin[NSIZE+1];
   char buf[MAXSTRLEN+1],syc[64];
   char ngFmtCh;

   if (trace&T_TIO)
      printf("\nBOffB "),fflush(stdout);

   if(InitSource(fn,&source,LangModFilter)<SUCCESS)
      HError(8110,"ReadBoNGram: Can't open file %s", fn);
   GetInLine(buf);
   SyncStr(buf,"\\data\\");
   for (i=1;i<=NSIZE;i++) counts[i]=0;
   for (i=1;i<=NSIZE;i++) {
      GetInLine(buf);
      if (sscanf(buf, "ngram %d%c%d", &j, &ngFmtCh, &k)!=3 && i>1)
         break;
      if (i!=j || k==0) 
         HError(8150,"ReadBoNGram: %dGram count missing (%s)",i,buf);

      switch (ngFmtCh) {
      case '=':
         ngBin[j] = FALSE;
         break;
      case '~':
         ngBin[j] = TRUE;
         break;
      default:
         HError (9999, "ReadARPALM: unknown ngram format type '%c'", ngFmtCh);
      }
      counts[j]=k;
   }

   if (ngBin[1])
      HError (8113, "ReadARPALM: unigram must be stored as text");

   nglm=CreateBoNGram(lm,counts[1],counts);
   for (i=1;i<=nglm->nsize;i++) {
      sprintf(syc,"\\%d-grams:",i);
      SyncStr(buf,syc);
      ReadNGrams(nglm,i,nglm->counts[i], ngBin[i]);
   }
   SyncStr(buf,"\\end\\");
   CloseSource(&source);

   if (trace&T_TIO) {
      printf("\n NEntry==%d ",nglm->counts[0]);
      for(i=1;i<=nglm->nsize;i++)
         printf(" %d-Grams==%d",i,nglm->counts[i]);
      printf("\n\n");
      fflush(stdout);
   }
}
예제 #5
0
int CTwain::CloseSourceManager(HWND hwnd)
{
	CloseSource();			// close source if open

	if (nState >= SOURCE_MANAGER_OPEN) {
		TW_INT32 hwnd32 = (TW_INT32)(int)(DefWnd(hwnd));
		SM(DG_CONTROL, DAT_PARENT, MSG_CLOSEDSM, &hwnd32);
		if (nState >= SOURCE_MANAGER_OPEN && bTrace) ATLTRACE(_T("TWAIN:CLOSEDSM failed.\n"));
	}
	return (nState < SOURCE_MANAGER_OPEN);
}
예제 #6
0

static int trace = 0;

#define T_TOP   0001       /* top level tracing */

#define T_HDR   0002       /* show header processing */

#define T_HASH  0004       /* hash table tracing */

예제 #7
0
파일: HDict.c 프로젝트: botonchou/AlgoFinal
/* EXPORT->ReadDict: read and store a dictionary definition */
ReturnStatus ReadDict(char *dictFn, Vocab *voc)
{
   LabId labels[MAXPHONES+4];
   Source src;
   Word word;
   float prob;
   int nphones;
   ReturnStatus ret;

   if(InitSource(dictFn,&src,DictFilter)<SUCCESS){
      HRError(8010,"ReadDict: Can't open file %s", dictFn);
      return(FAIL);
   }
   if (trace&T_TOP)
      printf("\nLoading Dictionary from %s\n",dictFn);
   if((ret=ReadDictWord(&src,labels,&prob, &nphones))<SUCCESS){
      CloseSource(&src);
      HRError(8013,"ReadDict: Dict format error in first entry");
      return(FAIL);
   }
   while(nphones>=0){
      word = GetWord(voc,labels[0],TRUE);
      if (labels[1]==NULL) labels[1]=labels[0];
      if (labels[1]->name[0]==0) labels[1]=NULL;
      if (voc->nullWord->wordName == word->wordName)
         HRError(-8013,"ReadDict: !NULL entry contains pronunciation");
      NewPron(voc,word,nphones,labels+2,labels[1],prob);
      if((ret=ReadDictWord(&src,labels,&prob, &nphones))<SUCCESS){
         HRError(8013,"ReadDict: Dict format error");
         return(FAIL);
      }
   }
   CloseSource(&src);

   if (trace&T_DIC)
      ShowDict(voc);
   if (trace&T_TOP)
      printf("Dictionary loaded from %s with %d words and %d prons\n\n",
             dictFn,voc->nwords,voc->nprons);
   return(SUCCESS);
}
예제 #8
0
/* EXPORT->LoadStatsFile: load the statistics file output by HERest */
void LoadStatsFile(char *statfile,HMMSet *hset,Boolean otrace)
{
   Source src;
   char hname[256];
   int i,idx,count,N,lnum = 0;
   float x;
   HMMDef *hmm;
   MLink ml;
   LabId hmmId;
   double occSum = 0.0;
   long occN = 0;
   StateInfo *si;
   Boolean bin=FALSE;

   if(InitSource(statfile,&src,NoFilter)<SUCCESS)
      HError(7210,"LoadStatsFile: Can't open file %s", statfile);
   while(ReadInt(&src,&idx,1,bin)) {
      ++lnum;
      if (!ReadString(&src,hname) || !ReadInt(&src,&count,1,bin))
         HError(7250,"LoadStatsFile: Format error in file %s line %d",
                statfile,lnum);

      /* look up hname and find num states N */
      if ((hmmId = GetLabId(hname,FALSE))==NULL)
         HError(7251,"LoadStatsFile: unknown name %s at line %d",
                hname,lnum);
      if ((ml = FindMacroName(hset,'l',hmmId))==NULL)
         HError(7251,"LoadStatsFile: unknown model %s at line %d",
                hname,lnum);
      hmm = (HMMDef *) ml->structure;
      N = hmm->numStates;
      for (i=2; i<N; i++) {
         if (!ReadFloat(&src,&x,1,bin))
            HError(7250,"LoadStatsFile: Float format error file %s line %d\n",
                   statfile,lnum);
         si = hmm->svec[i].info;
         si->stateCounter = count;/* load the # of times the state occurred */
         memcpy(&(si->hook),&x,sizeof(float)); /* !! */
         occSum += x; ++occN;
      }
   }
   CloseSource(&src);
   if (otrace || (trace & T_OCC)) {
      printf("  Stats loaded for %d models\n",lnum);
      printf("  Mean Occupation Count = %f\n",occSum/occN);
      fflush(stdout);
   }
}
// destruktor
CDataSourcesManager::~CDataSourcesManager()
{
	// kody: zavreni vsech datovych zdroju (kvuli Ferdovi)
	// ***
	saveSourcesTab();

	for (int i = 0;  i < SourcesTab.GetSize(); i++)
	{
		try
		{
			if(isSourceConnected(i))
				CloseSource(i);
		}
		catch(...) {}

		delete SourcesTab[i];
	}

	// ***
	
}
예제 #10
0
void FCDProThread::run()
{
	if ( !OpenSource(fcd_traits<Pro>::alsaDeviceName) )
	{
		qCritical() << "FCDThread::run: cannot open FCD sound card";
		return;
	}
	// TODO: fallback to original fcd

	m_running = true;

	while(m_running)
	{
		if (work(fcd_traits<Pro>::convBufSize) < 0)
		{
			break;
		}
	}

	CloseSource();
}
예제 #11
0
void CTwain::CloseDsRequest(void)
{
	CloseSource();
}
예제 #12
0
/* SetConfParms: set conf parms relevant to HCompV  */

void SetConfParms(void)

{

   int i;

   Boolean b;

   double f;

   char buf[MAXSTRLEN];

   

   nParm = GetConfig("HEREST", TRUE, cParm, MAXGLOBS);

   if (nParm>0) {

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

      if (GetConfFlt(cParm,nParm,"VARFLOORPERCENTILE",&f)) varFloorPercent = f;

      if (GetConfBool(cParm,nParm,"SAVEBINARY",&b)) saveBinary = b;

      if (GetConfBool(cParm,nParm,"BINARYACCFORMAT",&b)) ldBinary = b;

      /* 2-model reestimation alignment model set */

      if (GetConfStr(cParm,nParm,"ALIGNMODELMMF",buf)) {

          strcpy(al_hmmMMF,buf); al_hmmUsed = TRUE;

      }

      if (GetConfStr(cParm,nParm,"ALIGNHMMLIST",buf)) {

          strcpy(al_hmmLst,buf); al_hmmUsed = TRUE;

      }

      /* allow multiple individual model files */

      if (GetConfStr(cParm,nParm,"ALIGNMODELDIR",buf)) {

          strcpy(al_hmmDir,buf); al_hmmUsed = TRUE;

      }

      if (GetConfStr(cParm,nParm,"ALIGNMODELEXT",buf)) {

          strcpy(al_hmmExt,buf); al_hmmUsed = TRUE;

      }

      if (GetConfStr(cParm,nParm,"ALIGNXFORMEXT",buf)) {

         xfInfo.alXFormExt = CopyString(&hmmStack,buf);

      }

      if (GetConfStr(cParm,nParm,"ALIGNXFORMDIR",buf)) {

         xfInfo.alXFormDir = CopyString(&hmmStack,buf);

      }

      if (GetConfStr(cParm,nParm,"INXFORMMASK",buf)) {

         xfInfo.inSpkrPat = CopyString(&hmmStack,buf);

      }

      if (GetConfStr(cParm,nParm,"PAXFORMMASK",buf)) {

         xfInfo.paSpkrPat = CopyString(&hmmStack,buf);

      }

      if (GetConfStr(cParm,nParm,"LABFILEMASK",buf)) {

         labFileMask = (char*)malloc(strlen(buf)+1); 

         strcpy(labFileMask, buf);

      }



      if (GetConfStr(cParm,nParm,"UPDATEMODE",buf)) {

         if (!strcmp (buf, "DUMP")) updateMode = UPMODE_DUMP;

         else if (!strcmp (buf, "UPDATE")) updateMode = UPMODE_UPDATE;

         else if (!strcmp (buf, "BOTH")) updateMode = UPMODE_BOTH;

         else HError(2319, "Unknown UPDATEMODE specified (must be DUMP, UPDATE or BOTH)");

      }

   }

}



void ReportUsage(void)

{

   printf("\nUSAGE: HERest [options] hmmList dataFiles...\n\n");

   printf(" Option                                       Default\n\n");

   printf(" -a      Use an input linear transform        off\n");

   printf(" -c f    Mixture pruning threshold            10.0\n");

   printf(" -d s    dir to find hmm definitions          current\n");

   printf(" -h s    set output speaker name pattern   *.%%%%%%\n");

   printf("         to s, optionally set input and parent patterns\n");

   printf(" -l N    set max files per speaker            off\n");

   printf(" -m N    set min examples needed per model    3\n");

   printf(" -o s    extension for new hmm files          as src\n");

   printf(" -p N    set parallel mode to N               off\n");

   printf(" -r      Enable Single Pass Training...       \n");

   printf("         ...using two parameterisations       off\n");

   printf(" -s s    print statistics to file s           off\n");

   printf(" -t f [i l] set pruning to f [inc limit]      inf\n");

   printf(" -u tmvwap  update t)rans m)eans v)ars w)ghts tmvw\n");

   printf("                a)daptation xform p)rior used     \n");

   printf("                s)semi-tied xform                 \n");

   printf(" -v f    set minimum variance to f            0.0\n");

   printf(" -w f    set mix weight floor to f*MINMIX     0.0\n");

   printf(" -x s    extension for hmm files              none\n");

   printf(" -z s    Save all xforms to TMF file s        TMF\n");

   PrintStdOpts("BEFGHIJKLMSTX");

   printf("\n\n");

}



void SetuFlags(void)

{

   char *s;

   

   s=GetStrArg();

   uFlags=(UPDSet) 0;        

   while (*s != '\0')

      switch (*s++) {

      case 't': uFlags = (UPDSet) (uFlags+UPTRANS); break;

      case 'm': uFlags = (UPDSet) (uFlags+UPMEANS); break;

      case 'v': uFlags = (UPDSet) (uFlags+UPVARS); break;

      case 'w': uFlags = (UPDSet) (uFlags+UPMIXES); break;

      case 's': uFlags = (UPDSet) (uFlags+UPSEMIT); break;

      case 'a': uFlags = (UPDSet) (uFlags+UPXFORM); break;

      case 'p': uFlags = (UPDSet) (uFlags+UPMAP); break;

      default: HError(2320,"SetuFlags: Unknown update flag %c",*s);

         break;

      }

}



/* ScriptWord: return next word from script */

char *ScriptWord(FILE *script, char *scriptBuf)

{

   int ch,qch,i;

   

   i=0; ch=' ';

   while (isspace(ch)) ch = fgetc(script);

   if (ch==EOF) {

      scriptBuf=NULL;

      return NULL;

   }

   if (ch=='\'' || ch=='"'){

      qch = ch;

      ch = fgetc(script);

      while (ch != qch && ch != EOF) {

         scriptBuf[i++] = ch; 

         ch = fgetc(script);

      }

      if (ch==EOF)

         HError(5051,"ScriptWord: Closing quote missing in script file");

   } else {

      do {

         scriptBuf[i++] = ch; 

         ch = fgetc(script);

      }while (!isspace(ch) && ch != EOF);

   }

   scriptBuf[i] = '\0';



   return scriptBuf;

}



void CheckUpdateSetUp()

{

  AdaptXForm *xf;
예제 #13
0
파일: asl.c 프로젝트: mingpen/OpenNT
VOID
__cdecl main (
    IN int      argc,
    IN char     **argv
    )
{
    //
    // Initialize
    //

    InitParse ();
    ParseArgs (argc, argv);
    InitializeListHead (&VerifyRef);

    if (!Source) {
        HelpAndExit (NULL);
    }

    printf ("ACPI Souce Language Assembler Version 0.1\n");
    printf ("Copyright (C) Microsoft Corp 1996. All rights reserved.\n");
    fflush (stdout);

    //
    // Build top level scope & ASL data package for which image
    // can be built in
    //

    DataImage = AllocAl();
    DataImage->Name     = AllocName();
    DataImage->Flags   |= F_AMLPACKAGE | F_PVARIABLE;
    DataImage->Term     = &ImageTerm;
    DataImage->Parent   = DataImage;
    DataImage->DataType = TypeRoot;
    InitializeListHead(&DataImage->FixedList);
    InitializeListHead(&DataImage->u1.VariableList);
    DataImage->Name->NameSeg = (ULONG) '\\';
    AlLoc = DataImage;

    //
    // Parse source
    //

    while (Source) {
        ParseSource ();
        CloseSource ();
    }

    if (Verbose > 1) {
        printf ("NameSpaceDump:\n");
        DumpNameSpace (DataImage->Name, 0);

        //not valid anymore...
        //if (Verbose > 2) {
        //    DumpImage();
        //    printf ("AMLSize %d\n", AMLSize);
        //}
    }

    //
    // Enable AML for data image, and calculate package sizes
    //

    DataImage->Flags |= F_AMLENCODE;
    WriteDefinitionBlocks (DataImage);

    //
    // Remove AML package size from image Al
    //

    DataImage->Flags &= ~F_AMLENCODE;
    DataImage->u.Data.Length = 0;


    //
    // ...
    //

    Terminate ();
}
예제 #14
0
int main(int argc, char *argv[])
{
   Source src;
   int tmpInt;
   float tmpFlt;
   char *accfn, *s;

   void Initialise(char *hmmListFn);
   void Interpolate(void);
   void UpdateModels(void);
   void MakeWtAccLists(void);
   void AttachWtAccLists(void);
   void StatReport(void);
   
   if(InitShell(argc,argv,hsmooth_version,hsmooth_vc_id)<SUCCESS)
      HError(2400,"HSmooth: InitShell failed");

   InitMem();   InitLabel();
   InitMath();  InitSigP();
   InitWave();  InitAudio();
   InitVQ();    InitModel();
   if(InitParm()<SUCCESS)  
      HError(2400,"HSmooth: InitParm failed");

   InitTrain(); InitUtil();

   if (!InfoPrinted() && NumArgs() == 0)
      ReportUsage();
   if (NumArgs() == 0) Exit(0);

   SetConfParms();
   CreateHeap(&hmmStack,"HmmStore", MSTAK, 1, 1.0, 50000, 500000);
   CreateHMMSet(&hset,&hmmStack,TRUE);
   while (NextArg() == SWITCHARG) {
      s = GetSwtArg();
      if (strlen(s)!=1) 
         HError(2419,"HSmooth: Bad switch %s; must be single letter",s);
      switch(s[0]){
      case 'b':
         epsilon = GetChkedFlt(0.0,1.0,s); break;           
      case 'c':
         maxStep = GetChkedInt(1,1000,s); break;            
      case 'd':
         if (NextArg()!=STRINGARG)
            HError(2419,"HSmooth: HMM definition directory expected");
         hmmDir = GetStrArg(); break;  
      case 'e':
         if (NextArg()!=STRINGARG)
            HError(2419,"HSmooth: HMM definition directory expected");
         newDir = GetStrArg(); break;  
      case 'm':
         minEgs = GetChkedInt(1,1000,s); break;
      case 'o':
         if (NextArg()!=STRINGARG)
            HError(2419,"HSmooth: HMM file extension expected");
         newExt = GetStrArg(); break;
      case 's':
         stats = TRUE;
         if (NextArg()!=STRINGARG)
            HError(2419,"HSmooth: Stats file name expected");
         statFN = GetStrArg(); break;
      case 'u':
         SetuFlags(); break;
      case 'v':
         minVar = GetChkedFlt(0.0,10.0,s); break;
      case 'w':
         mixWeightFloor = MINMIX * GetChkedFlt(0.0,10000.0,s); 
         break;
      case 'x':
         if (NextArg()!=STRINGARG)
            HError(2419,"HSmooth: HMM file extension expected");
         hmmExt = GetStrArg(); break;
      case 'B':
         saveBinary=TRUE;
         break;
      case 'H':
         if (NextArg() != STRINGARG)
            HError(2419,"HSmooth: HMM macro file name expected");
         AddMMF(&hset,GetStrArg());
         break;
      case 'M':
         if (NextArg()!=STRINGARG)
            HError(2419,"HSmooth: Output macro file directory expected");
         newDir = GetStrArg();
         break;    
      case 'T':
         trace = GetChkedInt(0,0100000,s); break;
      default:
         HError(2419,"HSmooth: Unknown switch %s",s);
      }
   } 
   if (NextArg() != STRINGARG)
      HError(2419,"HSmooth: file name of HMM list expected");
   Initialise(GetStrArg());
   do {
      if (NextArg()!=STRINGARG)
         HError(2419,"HSmooth: accumulator file name expected");
      accfn = GetStrArg();
      src=LoadAccs(&hset,accfn,uFlags);
      ReadFloat(&src,&tmpFlt,1,ldBinary);
      totalPr += (LogDouble)tmpFlt;
      ReadInt(&src,&tmpInt,1,ldBinary);
      totalT += tmpInt;
      CloseSource(&src);      
      nBlk++;
      MakeWtAccLists();
   } while (NumArgs()>0);
   AttachWtAccLists();
   Interpolate();
   if (stats) StatReport();
   UpdateModels();
   Exit(0);
   return (0);          /* never reached -- make compiler happy */
}
예제 #15
0
/* ReadBigram: load a bigram from given file */
static void ReadMatBigram(LModel *lm,char *fn)
{
   Vector vec;
   char buf[132];
   int P,p,j;
   float sum,x;
   LabId id;
   MatBiLM *matbi;
  
   if (trace&T_TIO)
      printf("\nMB "),fflush(stdout);

   if(InitSource(fn,&source,LangModFilter)<SUCCESS)
      HError(8110,"ReadMatBigram: Can't open file %s", fn);
   vec = CreateVector(&gcheap,MAX_LMID);
   ReadLMWord(buf);SkipWhiteSpace(&source);
   id=GetLabId(buf,TRUE);
   P = ReadRow(vec);

   if (P<=0 || P >MAX_LMID)
      HError(8151,"ReadMatBigram: First row invalid (%d entries)",P);

   matbi=CreateMatBigram(lm,P);

   matbi->wdlist[1] = id;
   for (p=1;p<=P;p++) matbi->bigMat[1][p]=vec[p];
   id->aux=(Ptr) 1;
   Dispose(&gcheap,vec);

   for (sum=0.0, j=1; j<=P; j++) {
      x = matbi->bigMat[1][j];
      if (x<0)
         HError(8151,"ReadMatBigram: In bigram, entry %d for %s is -ve (%e)",
                j,buf,x);
      sum += x;
      matbi->bigMat[1][j]=((x<MINLARG)?LZERO:log(x));
   }
   if (sum < 0.99 || sum > 1.01)
      HError(-8151,"ReadMatBigram: Row %d of bigram %s adds up to %f",1,fn,sum);

   for (p=2; ReadLMWord(buf); p++) {
      if (trace&T_TIO) {
         if ((p%25)==0)
            printf(". "),fflush(stdout);
         if ((p%800)==0)
            printf("\n   "),fflush(stdout);
      }
      if (p>P)
         HError(8150,"ReadMatBigram: More rows than columns in bigram %s",fn);
      id=GetLabId(buf,TRUE);
      if ((int)id->aux != 0) 
         HError(8150,"ReadMatBigram: Duplicated name %s in bigram %s",buf,fn);
      id->aux = (Ptr) p;
      matbi->wdlist[p] = id;
      SkipWhiteSpace(&source);
      if (ReadRow(matbi->bigMat[p])!=P)
         HError(8150,"ReadMatBigram: Wrong number of items in row %d",p);
      for (sum=0.0, j=1; j<=P; j++) {
         x = matbi->bigMat[p][j];
         if (x<0)
            HError(8151,"ReadMatBigram: In bigram, entry %d for %s is -ve (%e)",
                   j,buf,x);
         sum += x;
         matbi->bigMat[p][j]=((x<MINLARG)?LZERO:log(x));
      }
      if (sum < 0.99 || sum > 1.01)
         HError(-8151,"ReadMatBigram: Row %d of bigram %s adds up to %f",p,fn,sum);
   }
   if (P>p)
      HError(8150,"ReadMatBigram: More columns than rows in bigram %s",fn);
   if (trace&T_TIO)
      printf("\n"),fflush(stdout);
   CloseSource(&source);
}