public static void Main(string[] args) { if (args.Length != 0) InputManager.ReadFile (args [0]); if ((InputManager.HmmList.Count == 0) || (InputManager.Sequence.Count == 0)) Console.WriteLine ("Empty input"); InputManager.HmmList.Find (x => x.Name == "B").IsFirst = true; InputManager.HmmList.Find (x => x.Name == "E").IsFinal = true; // forward-backward run ForwardBackward FB = new ForwardBackward (InputManager.HmmList, InputManager.Sequence); FB.CalcBackward (); FB.CalcForward (); // // ExportForwardBackwardResults.Export(FB,args [0] + "_Result"); // viterbi run Viterbi V = new Viterbi(InputManager.HmmList, InputManager.Sequence); V.RunViterbi(); string[] MaxProbPath = GetMaxProbPath(V); // results for (double Limit = 0.1; Limit < 0.99; Limit += 0.1) ShowStatistics(FB, MaxProbPath, Limit); }
private static string[] GetMaxProbPath(Viterbi V) { string[] MaxProbPath = new string[InputManager.Sequence.Count + 2]; HMM Hmm = InputManager.HmmList.Find (x => x.Name == "E"); for(int I = InputManager.Sequence.Count + 1; I >= 0; I--) { ViterbiResult VR = V.GetResult(I, Hmm); MaxProbPath[I] = VR.StateName; Hmm = InputManager.HmmList.Find(x => x.Name == VR.PrevStateName); } return MaxProbPath; }