void MergeStates(void) { int Classes, S, S1, E, Sh; State SP, SP1, QL, QR; ETab = 0; EMax = 0; for (S = 0; S < Ss; S++) { SP = &STab[S]; if (SP->Class != S) continue; for (S1 = 0; S1 < S; S1++) { SP1 = &STab[S1]; if (SP1->Class != S1) continue; Es = 0; AddEquiv(S, S1); for (E = 0; E < Es; E++) { QL = ETab[E].L; QR = ETab[E].R; if (QL->Empty != QR->Empty || QL->Shifts != QR->Shifts) goto NOT_EQUAL; for (Sh = 0; Sh < QL->Shifts; Sh++) if (QL->ShList[Sh].LHS != QR->ShList[Sh].LHS) goto NOT_EQUAL; for (Sh = 0; Sh < QL->Shifts; Sh++) AddEquiv(QL->ShList[Sh].RHS, QR->ShList[Sh].RHS); } /* EQUAL: */ break; NOT_EQUAL: continue; } if (S1 < S) for (E = 0; E < Es; E++) { State QL = ETab[E].L; QR = ETab[E].R; QR->Class = QL->Class; } } for (Classes = 0, S = 0; S < Ss; S++) { SP = &STab[S]; SP->Class = (SP->Class == S) ? Classes++ : STab[SP->Class].Class; } }
void MergeStates(void) { int Classes, S, S1, E; Exp Q, Q1, L, R; ETab = 0, EMax = 0; for (S = 1; S < Ss; S++) { Q = STab[S]; if (Q->State < S) continue; for (S1 = 0; S1 < S; S1++) { int LX, RX; Q1 = STab[S1]; if (Q1->State < S1) continue; Es = 0, AddEquiv(Q, Q1); for (E = 0; E < Es; E++) { L = ETab[E].L, R = ETab[E].R; if (L->Unit != R->Unit) goto NOT_EQUAL; for (LX = 0, RX = 0; LX < L->Terms && RX < R->Terms; ) { int Diff = strcmp(L->Sum[LX].X->Name, R->Sum[RX].X->Name); if (Diff < 0) AddEquiv(STab[0], L->Sum[LX++].Q); else if (Diff > 0) AddEquiv(STab[0], R->Sum[RX++].Q); else AddEquiv(L->Sum[LX++].Q, R->Sum[RX++].Q); } for (; LX < L->Terms; LX++) AddEquiv(STab[0], L->Sum[LX].Q); for (; RX < R->Terms; RX++) AddEquiv(STab[0], R->Sum[RX].Q); } // EQUAL: break; NOT_EQUAL: continue; } if (S1 < S) for (E = 0; E < Es; E++) ETab[E].R->State = ETab[E].L->State; } for (Classes = 0, S = 0; S < Ss; S++) { Q = STab[S]; Q->State = (Q->State < S)? STab[Q->State]->State: Classes++; } }
int main(int argc, char *argv[]) { int i; char *s,*c,*e; InitShell(argc,argv,lplex_version,lplex_vc_id); InitMem(); InitMath(); InitWave(); InitLabel(); InitWMap(); InitCMap(); InitLUtil(); InitLModel(); InitPCalc(); InitPMerge(); SetConfParms(); if (!InfoPrinted() && NumArgs() == 0) ReportUsage(); if (NumArgs() == 0) Exit(EXIT_SUCCESS); nLModel = 1; for (i=1; i<=LM_NSIZE; i++) cutOff[i] = 0, wdThresh[i] = 0.0; CreateHeap(&permHeap, "permHeap", MSTAK, 1, 1.0, 4000, 20000); CreateHeap(&tempHeap, "tempHeap", MSTAK, 1, 1.0, 8000, 40000); while (NextArg() == SWITCHARG) { s = GetSwtArg(); if (strlen(s)!=1) HError(16619,"Bad switch %s; must be single letter",s); switch(s[0]){ case 'c': i = GetChkedInt(2,LM_NSIZE,s); cutOff[i] = GetChkedInt(1,1000,s); break; case 'd': i = GetChkedInt(2,LM_NSIZE,s); wdThresh[i] = GetChkedFlt(0.0,1E10,s); break; case 'e': if (NextArg() != STRINGARG) HError(16619,"LPlex: Eq Class Name Expected"); c = GetStrArg(); if (NextArg() != STRINGARG) HError(16619,"LPlex: Eq Label Name Expected"); e = GetStrArg(); AddEquiv(c,e); break; case 'i': if (NextArg()!=FLOATARG) HError(16619,"LPlex: Interpolation weight expected"); lmInfo[nLModel].weight = GetChkedFlt(0.0,1.0,s); if (NextArg()!=STRINGARG) HError(16619,"LPlex: Interpolation LM filename expected"); lmInfo[nLModel].fn = GetStrArg(); nLModel++; break; case 'n': testInfo[numTests++] = GetChkedInt(1, 10, s); break; case 'o': printOOV = TRUE; break; case 's': if (NextArg() != STRINGARG) HError(16619,"LPlex: Prob Stream file name expected"); outStreamFN = GetStrArg(); break; case 't': streamMode = TRUE; break; case 'u': skipOOV = FALSE; break; case 'w': if (NextArg() != STRINGARG) HError(16619,"LPlex: Word list file name expected"); wlistFN = GetStrArg(); break; case 'z': if (NextArg() != STRINGARG) HError(16619,"LPlex: New null class name expected"); nulName = GetStrArg(); break; case 'G': if (NextArg() != STRINGARG) HError(16619,"Label File format expected"); if((lff = Str2Format(GetStrArg())) == ALIEN) HError(16619,"Warning ALIEN Label file format set"); break; case 'I': if (NextArg() != STRINGARG) HError(16619,"MLF file name expected"); LoadMasterFile(GetStrArg()); break; case 'T': trace = GetChkedInt(0,077, s); break; default: HError(16619,"LPlex: Unknown switch %s",s); } } #ifdef HTK_TRANSCRIBER if (trace&T_PROB) trace=trace^T_PROB; #endif if (NextArg()!=STRINGARG) /* load the language model */ HError(16619, "Language model filename expected"); lmInfo[0].fn = GetStrArg(); Initialise(); ProcessFiles(); Exit(EXIT_SUCCESS); return EXIT_SUCCESS; /* never reached -- make compiler happy */ }