private static void TestLoadedModel(WordModel model) { Assert.IsNotNull(model); Assert.AreEqual(4501, model.Words); Assert.AreEqual(100, model.Size); Assert.AreEqual(4501, model.Vectors.Count()); Assert.IsTrue(model.Vectors.Any(x => x.Word == "whale")); var whale = model.GetByWord("whale"); Assert.IsNotNull(whale); var xyz = model.GetByWord("xyz"); Assert.IsNull(xyz); var results = model.Nearest(whale.Vector).Take(10).ToArray(); Assert.AreEqual(10, results.Length); Assert.AreEqual("whale", results[0].Word); var results2 = model.Nearest("whale").Take(10).ToArray(); Assert.AreEqual(10, results2.Length); Assert.AreNotEqual("whale", results2[0].Word); Assert.AreEqual("whale,", results2[0].Word); var nearest = model.NearestSingle(model.GetByWord("whale").Subtract(model.GetByWord("sea"))); Assert.IsNotNull(nearest); Assert.AreNotEqual(0, model.Distance("whale", "boat")); var king = model.GetByWord("whale"); var man = model.GetByWord("boat"); var woman = model.GetByWord("sea"); var vector = king.Subtract(man).Add(woman); Console.WriteLine(model.NearestSingle(vector)); var sentences = new[] { new SentenceItem(), new SentenceItem() }; sentences[0].Words.Add(new WordEx("whale")); sentences[0].Words.Add(new WordEx("boat")); sentences[1].Words.Add(new WordEx("whale")); sentences[1].Words.Add(new WordEx { Raw = "boat" }); var paragraph = model.GetParagraphVector(sentences); var paragraph2 = model.GetParagraphVector(sentences.Take(1).ToArray()); Assert.AreEqual(paragraph2, paragraph); }