예제 #1
0
        public void ModellingATwoStateProcess()
        {
            List <string> states = new List <string>();

            states.Add("word");
            states.Add("end");

            model.Learn("word end");

            Assert.IsTrue(states.Contains(model.RandomState()));
            Assert.AreEqual("end", model.NextState("word"));
            Assert.AreEqual(null, model.NextState("end"));
        }
예제 #2
0
        static void Main(string[] args)
        {
            MarkovModel model         = new MarkovModel();
            string      training_text = System.IO.File.ReadAllText(@"D:\jorch\Code\code_katas\MarkovChainTextCSharp\MarkovChainTextCSharp\sample.txt");

            model.Learn(training_text);

            string word = "The";

            foreach (int i in Enumerable.Range(0, 200))
            {
                Console.Write(word);
                word = model.NextState(word);

                if (word != null)
                {
                    Console.Write(" ");
                }
                else
                {
                    break;
                }
            }

            Console.WriteLine("");
        }