public void LoadAndLearn() { var wvl =new WordVectorLoader("wikipedia_vectors.txt"); var sw = Stopwatch.StartNew(); _wordVectors = wvl.LoadVectors(); sw.Stop(); Debug.WriteLine("Loaded word vectors in {0} ms", sw.ElapsedMilliseconds); var s = new StoryReader("WikiJunior_Biology.txt"); var sentences = s.ReadStory(); _contextMaps = new ContextMaps(); _sentenceLearner = new SentenceLearner(_wordVectors, sentences, _contextMaps); var plan = _sentenceLearner.PreparePlan(12); _sentenceLearner.ExecutePlan(plan, MorphoSyntacticContext.InitialState()); }
public void TestTrain2() { var stream = new StringReader(@"Hey! Look here!"); var storyReader = new StoryReader(stream); var sentences = storyReader.ReadStory(); var wordVectors = new WordVectors(10); var contextMaps = new ContextMaps(); wordVectors.TryAdd("Hey", new WordVector { Name = "Hey" }); wordVectors.TryAdd("Look", new WordVector { Name = "Look" }); wordVectors.TryAdd("here", new WordVector { Name = "here" }); wordVectors.TryAdd("Test", new WordVector { Name = "Test" }); wordVectors.TryAdd("!", new WordVector { Name = "!" }); var target = new SentenceLearner(wordVectors, sentences, contextMaps); var plan = target.PreparePlan(4); target.ExecutePlan(plan, MorphoSyntacticContext.InitialState()); var weights = target.GetWeightsForWord(new WrittenWord("Hey")); }