/// <summary> /// Selects a random word within the first 10000 heaviest connected words of the training word. /// </summary> /// <returns>The word instance if found, the default end word otherwise.</returns> internal WordInstance SelectWord() { var sortedWords = PostWords.OrderByDescending(td => td.Value.Weight).Take(Math.Min(PostWords.Count, 10000)).ToList(); if (sortedWords.Count == 0) { return(DefaultEndWord); } return(sortedWords[WordRand.Next(0, sortedWords.Count)].Value); }
/// <summary> /// Selects a starting word for a sentence. /// </summary> /// <returns>The word instance.</returns> internal WordInstance SelectStartWord() { var sortedWords = _trainingData.Where(w => !_symbolHashes.Contains(w.Key) || w.Value.SymbolType == SymbolType.Wrapper).OrderByDescending(td => td.Value.Weight).Take(Math.Min(_trainingData.Count, 10000)).ToList(); return(sortedWords[WordRand.Next(0, sortedWords.Count)].Value); }