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))); } }
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)); }
public void SimpleLearner_Learn_WithEmptyInput_LearnsNothing() { var learner = new SimpleLearner <object>(); learner.Learn(new object[0]); Assert.That(learner.GetStates(), Is.Empty); }
public void SimpleLearner_Learn_WithSingleItemInput_LearnsNothing() { var learner = new SimpleLearner <char>(); learner.Learn(new[] { 'a' }); Assert.That(learner.GetStates(), Is.Empty); }
public void SimpleLearner_Learn_WithNullInput_ThrowsArgumentNullException() { var learner = new SimpleLearner <object>(); Assert.That(() => learner.Learn(null), Throws.ArgumentNullException); }