public void MarkovGenerator_Dummy()
        {
            string[] data = new[]
            {
                "martin",
                "bernard",
                "thomas",
                "petit",
                "robert",
                "richard",
                "durand",
                "dubois",
                "moreau",
                "laurent"
            };

            var learner = new SimpleLearner <char>();

            learner.Learn(data);

            var generator = new MarkovGenerator <char>(learner.GetStates());

            var strings = new List <string>();

            for (int i = 0; i < 100; i++)
            {
                strings.Add(string.Concat(generator.Generate(10)));
            }
        }
Example #2
0
        public void SimpleLearner_Learn_WithAppropriateInput_Learns()
        {
            var    learner = new SimpleLearner <char>();
            string input   = "abcadbbbabe";

            learner.Learn(input.ToCharArray());

            IDictionary <char, MarkovState <char> > states = learner.GetStates();

            Assert.That(states, Has.Count.EqualTo(5));

            Assert.That(states['a'].Links, Has.Count.EqualTo(2));
            Assert.That(states['b'].Links, Has.Count.EqualTo(4));
            Assert.That(states['c'].Links, Has.Count.EqualTo(1));
            Assert.That(states['d'].Links, Has.Count.EqualTo(1));
            Assert.That(states['e'].Links, Is.Empty);

            Assert.That(states['a'].Links[states['b']], Is.EqualTo(2));
            Assert.That(states['a'].Links[states['d']], Is.EqualTo(1));

            Assert.That(states['b'].Links[states['c']], Is.EqualTo(1));
            Assert.That(states['b'].Links[states['a']], Is.EqualTo(1));
            Assert.That(states['b'].Links[states['b']], Is.EqualTo(2));
            Assert.That(states['b'].Links[states['e']], Is.EqualTo(1));

            Assert.That(states['c'].Links[states['a']], Is.EqualTo(1));

            Assert.That(states['d'].Links[states['b']], Is.EqualTo(1));
        }
Example #3
0
        public void SimpleLearner_Learn_WithEmptyInput_LearnsNothing()
        {
            var learner = new SimpleLearner <object>();

            learner.Learn(new object[0]);

            Assert.That(learner.GetStates(), Is.Empty);
        }
Example #4
0
        public void SimpleLearner_Learn_WithSingleItemInput_LearnsNothing()
        {
            var learner = new SimpleLearner <char>();

            learner.Learn(new[] { 'a' });

            Assert.That(learner.GetStates(), Is.Empty);
        }
Example #5
0
        public void SimpleLearner_Learn_WithNullInput_ThrowsArgumentNullException()
        {
            var learner = new SimpleLearner <object>();

            Assert.That(() => learner.Learn(null), Throws.ArgumentNullException);
        }