/// <summary> /// Gets the state machine for printable ASCII bigram strings. /// </summary> /// <returns></returns> public static StateMachine GetAsciiString_BigramWithPrintable() { StateMachine asciiString = new StateMachine { Name = MachineList.Test_AsciiBigramWithPrintable }; BigramState asciiChar1 = new BigramState() { Name = "AsciiChar1", ParentStateMachine = asciiString }; BigramState asciiChar2 = new BigramState() { Name = "AsciiChar2", ParentStateMachine = asciiString }; State printableChar1 = new State() { Name = "PrintableChar", ParentStateMachine = asciiString }; asciiString.AddState(asciiChar1); asciiString.AddState(asciiChar2); asciiString.AddState(printableChar1); asciiString.StartingStates.Add(asciiChar1); asciiString.EndingStates.Add(asciiChar1); asciiString.EndingStates.Add(asciiChar2); asciiString.EndingStates.Add(printableChar1); AddTransition(asciiChar1, asciiChar2, 0.95d); asciiChar1.RemainingProbability = 0.01d; AddTransition(asciiChar2, asciiChar1, 0.95d); asciiChar2.RemainingProbability = 0.01d; AddTransition(asciiChar1, printableChar1, 0.05d); AddTransition(asciiChar2, printableChar1, 0.05d); AddTransition(printableChar1, asciiChar2, 0.49d); AddTransition(printableChar1, asciiChar2, 0.49d); printableChar1.RemainingProbability = 0.01; //Dash '-' printableChar1.PossibleValueProbabilities[0x2D] = 1d; return asciiString; }
/// <summary> /// Gets the state machine for ASCII string bigrams. /// </summary> /// <returns></returns> public static StateMachine GetAsciiString_Bigram_v1() { StateMachine asciiString = new StateMachine { Name = MachineList.Text_AsciiBigram }; BigramState asciiPart1 = new BigramState { Name = "AsciiPart1", ParentStateMachine = asciiString }; BigramState asciiPart2 = new BigramState { Name = "AsciiPart2", ParentStateMachine = asciiString }; BigramState asciiPart3 = new BigramState { Name = "AsciiPart3", ParentStateMachine = asciiString }; asciiString.AddState(asciiPart1); asciiString.AddState(asciiPart2); asciiString.AddState(asciiPart3); asciiString.StartingStates.Add(asciiPart1); asciiString.EndingStates.Add(asciiPart3); AddTransition(asciiPart1, asciiPart2, 0.1d); AddTransition(asciiPart1, asciiPart1, 0.9d); AddTransition(asciiPart2, asciiPart3, 0.1d); AddTransition(asciiPart2, asciiPart2, 0.9d); return asciiString; }
/// <summary> /// Gets the state machine for ASCII string bigrams. /// </summary> /// <returns></returns> public static StateMachine GetAsciiString_Bigram() { StateMachine asciiString = new StateMachine { Name = MachineList.Text_AsciiBigram }; BigramState asciiChar0 = new BigramState() { Name = "AsciiChar0", ParentStateMachine = asciiString }; BigramState asciiChar05 = new BigramState() { Name = "AsciiChar0.5", ParentStateMachine = asciiString }; //We have issue where the first letter of the ascii string is cut off. Hopefully this state will fix that. State asciiChar0_nonBigram = new State { Name = "AsciiChar0_nbg", ParentStateMachine = asciiString }; State asciiChar1_nonBigram = new State { Name = "AsciiChar1_nbg", ParentStateMachine = asciiString }; BigramState asciiChar1 = new BigramState() { Name = "AsciiChar1", ParentStateMachine = asciiString }; BigramState asciiChar2 = new BigramState() { Name = "AsciiChar2", ParentStateMachine = asciiString }; State printChar = new State { Name = "PrintChar", ParentStateMachine = asciiString }; asciiString.AddState(printChar); asciiString.AddState(asciiChar0_nonBigram); asciiString.AddState(asciiChar05); asciiString.AddState(asciiChar0); asciiString.AddState(asciiChar1); asciiString.AddState(asciiChar2); asciiString.AddState(asciiChar1_nonBigram); asciiString.StartingStates.Add(asciiChar0); asciiString.StartingStates.Add(asciiChar0_nonBigram); asciiString.EndingStates.Add(asciiChar1); asciiString.EndingStates.Add(asciiChar2); asciiString.EndingStates.Add(printChar); AddTransition(asciiChar0_nonBigram, asciiChar05, 0.9d); AddTransition(asciiChar0_nonBigram, asciiChar1_nonBigram, 0.1d); AddTransition(asciiChar1_nonBigram, asciiChar05, 1d); AddTransition(asciiChar0, asciiChar05, 1d); AddTransition(asciiChar0, asciiChar1_nonBigram, 0.1d); AddTransition(asciiChar05, asciiChar1, 0.88d); AddTransition(asciiChar05, printChar, 0.11d); AddTransition(asciiChar1, asciiChar2, 0.68d); asciiChar1.RemainingProbability = 0.01d; AddTransition(asciiChar2, asciiChar1, 0.68d); asciiChar2.RemainingProbability = 0.01d; AddTransition(asciiChar1, printChar, 0.31d); AddTransition(asciiChar2, printChar, 0.31d); AddTransition(printChar, asciiChar1, 0.88d); AddTransition(printChar, printChar, 0.11d); printChar.RemainingProbability = 0.01d; // all printable characters for (int i = 32; i < 127; i++) { printChar.PossibleValueProbabilities[i] = 1d; asciiChar0_nonBigram.PossibleValueProbabilities[i] = 1d; asciiChar1_nonBigram.PossibleValueProbabilities[i] = 1d; } printChar.NormalizeProbabilities(); asciiChar0_nonBigram.NormalizeProbabilities(); return asciiString; }