/* ReadRow: read a row from bigram file f into v */ int ReadRow(Vector v) { int i,j,N,cnt,c; float x; N = VectorSize(v); i=0; while(!source.wasNewline) { x = GetFloat(FALSE); c=GetCh(&source); if (c == '*') cnt=GetInt(); else { UnGetCh(c,&source); cnt=1; } SkipWhiteSpace(&source); for (j=0;j<cnt;j++) { i++; if (i<=N) v[i] = x; } } return(i); }
/* ReadLMWord: read a string from input stream */ static char *ReadLMWord(char *buf) { int i, c; if (rawMITFormat) { while (isspace(c=GetCh(&source))); i=0; while (!isspace(c) && c!=EOF && i<MAXSTRLEN){ buf[i++] = c; c=GetCh(&source); } buf[i] = '\0'; UnGetCh(c,&source); if (i>0) return buf; else return NULL; } else { if (ReadString(&source,buf)) return buf; else return NULL; } }
/* GetTrSym: get next symbol from f, remember that f might be an MLF in which case EOF is a period on its own line */ static void GetTrSym(Source *src, Boolean htk) { int nxtch; Boolean trSOL; trNum = 0.0; trStr[0]='\0'; if (trSym==TRNULL) curch = GetCh(src); if (trSym==TREOL || trSym==TRNULL) trSOL=TRUE; else trSOL=FALSE; while (curch == ' ' || curch == '\t') { trSOL=FALSE; curch = GetCh(src); } if (!htk && curch == COMMCHAR) SkipLine(src); switch (curch) { case EOF: trSym = TREOF; break; case LFEED: curch = GetCh(src); trSym = TREOL; break; case CRETURN: curch = GetCh(src); if (curch == LFEED) curch = GetCh(src); trSym = TREOL; break; case ',': if (!htk) { curch = GetCh(src); trSym = TRCOMMA; break; } case '.': if (curch=='.' && trSOL==TRUE && mlfUsed>0 && htk) { nxtch = GetCh(src); if (nxtch == LFEED || nxtch == CRETURN) { trSym = TREOF; break; } UnGetCh(nxtch,src); /* Requires more than one character pushback */ } default: if (htk) { UnGetCh(curch,src); if (!ReadString(src,trStr)) { trSym=TREOF; break; } curch=GetCh(src); if (trSOL && strcmp(LEVELSEP,trStr)==0) { if (curch == LFEED || curch == CRETURN) { trSym = TRLEV; break; } } } else { nxtch=0; do { if (nxtch>=255) break; trStr[nxtch++]=curch; curch=GetCh(src); } while (!isspace(curch) && curch != ',' && curch != EOF); trStr[nxtch]='\0'; src->wasQuoted=FALSE; } if (!src->wasQuoted && IsNumeric(trStr)){ sscanf(trStr,"%lf",&trNum); trSym = TRNUM; break; } if (htk && compatMode && (strcmp(LEVELSEP,trStr)==0 || strcmp(".",trStr)==0)) { src->wasNewline=FALSE; SkipWhiteSpace(src); if (src->wasNewline) { curch = CRETURN; trSym=(strcmp(LEVELSEP,trStr)==0?TRLEV:TREOF); break; } curch = GetCh(src); } if (stripTriPhones) TriStrip(trStr); trSym = TRSTR; break; } }