/* Initialise: initialise global data structures */ void Initialise(void) { float weight; char *fn; CreateWordMap(mapFN,&wmap,1); SortWordMap(&wmap); weight = 1.0; CreateInputSet(&gstack,&wmap,&inSet); while (NextArg() == STRINGARG || NextArg() == FLOATARG) { if (NextArg() == FLOATARG) weight = GetFltArg(); if (weight==0.0 || weight<-10000.0 || weight>10000.0) HError(-16719,"Unlikely ngram weight[%.4f]",weight); if (NextArg()!=STRINGARG) HError(16719,"Gram base file name expected"); fn = GetStrArg(); AddInputGFile(&inSet,fn,weight); if (trace&T_TOP) printf("Input file %s added, weight=%.4f\n",fn,weight); } if (nSize==0) nSize = inSet.N; }
/* Initialise: initialise global data structures */ void Initialise(void) { int i; char path[256]; CreateHeap(&langHeap,"LModel mem",MSTAK,1,0.5,1000,20000); if (wlistFN!=NULL) { tgtVoc = &wlist; CreateWordList(wlistFN,tgtVoc,10); } if (processText) { /* init empty buffer */ CreateWordMap(NULL,&wmap,newWords); wmap.hasCnts = TRUE; wmap.name = defMapName; wmap.htkEsc = htkEscape; ++wmap.seqno; mapUpdated = FALSE; if (tgtVoc!=NULL) { /* add words from word list to the map */ pruneWords = TRUE; for (i=0; i<tgtVoc->used; i++) { AddWordToMap(&wmap,tgtVoc->id[i]); } SortWordMap(&wmap); unkId = GetLabId(unkStr,FALSE); } /* init ngram buffer */ MakeFN(rootFN,dbsDir,NULL,path); stdBuf.used = 0; stdBuf.ng[nSize] = 1; /* count = 1 */ stdBuf.ngb = CreateNGBuffer(&langHeap,nSize,ngbSize,path,&wmap); } else { CreateWordMap(omapFN,&wmap,1); } CreateInputSet(&gstack,&wmap,&inSet); binfo.wmap = &wmap; binfo.inSet = &inSet; binfo.nSize = nSize; }
#include "LWMap.h" #include "LGBase.h" /* -------------------------- Trace Flags ------------------------ */ static int trace = 0; #define T_TOP 0001 /* Top Level tracing */ /* ---------------------- Global Variables ----------------------- */ static WordMap wmap; /* and the word map */ /* ---------------- Configuration Parameters --------------------- */ static ConfParam *cParm[MAXGLOBS]; static int nParm = 0; /* total num params */ /* ---------------- Process Command Line ------------------------- */ /* SetConfParms: set conf parms relevant to this tool */ void SetConfParms(void) { int i; nParm = GetConfig("LGLIST", TRUE, cParm, MAXGLOBS); if (nParm>0){ if (GetConfInt(cParm,nParm,"TRACE",&i)) trace = i;