public void RetrainingSetsCorrectDictionaryKeyLength(int retrainDepth)
        {
            var model = new StringMarkov();

            model.Learn(ExampleData);

            model.Retrain(retrainDepth);
            Assert.AreEqual(retrainDepth, model.Chain.ChainDictionary.Max(a => a.Key.Ngrams.Length));
        }
Ejemplo n.º 2
0
        public void RetrainingSetsCorrectLevel(int retrainDepth)
        {
            var model = new StringMarkov();

            model.Learn(ExampleData);
            Assert.AreEqual(2, model.Level);

            model.Retrain(retrainDepth);
            Assert.AreEqual(retrainDepth, model.Level);
        }
        public void RetrainValueMustBePositiveInteger(int retrainDepth)
        {
            var model = new StringMarkov();

            model.Learn(ExampleData);

            var ex = Assert.Throws <ArgumentException>(() => model.Retrain(retrainDepth));

            Assert.AreEqual("Invalid argument - retrain level must be a positive integer\r\nParameter name: newLevel", ex.Message);
        }
        public void SourceLinesAreSameAfterRetrained(int retrainDepth)
        {
            var model = new StringMarkov();

            model.Learn(ExampleData);
            var oldLines = new List <string>(model.SourcePhrases);

            model.Retrain(retrainDepth);
            CollectionAssert.AreEquivalent(oldLines, model.SourcePhrases);
        }
        public void RetrainedModelIsNotSameIfLevelIsDifferent(int retrainDepth, bool expectSameModel)
        {
            var model = new StringMarkov();

            model.Learn(ExampleData);
            var dict = new ConcurrentDictionary <NgramContainer <string>, List <string> >(model.Chain.ChainDictionary); // this will break for non string type models during testing until fixed

            model.Retrain(retrainDepth);

            if (expectSameModel)
            {
                //CollectionAssert.AreEquivalent(dict, model.Model);
                Assert.AreEqual(dict.Sum(a => a.Key.Ngrams.Count()), model.Chain.ChainDictionary.Sum(a => a.Key.Ngrams.Count()));
            }
            else
            {
                //CollectionAssert.AreNotEquivalent(dict, model.Model);
                Assert.AreNotEqual(dict.Sum(a => a.Key.Ngrams.Count()), model.Chain.ChainDictionary.Sum(a => a.Key.Ngrams.Count()));
            }
        }