/// <summary> /// Generates a random sentence which starts with a particular word pair. /// If the generator does not know about the pair, then a random pair will be chosen. /// </summary> /// <param name="startPair">The pair to start with.</param> /// <param name="random">The random number generator.</param> /// <returns>The words in the sentence.</returns> public IEnumerable <string> GenerateSentenceFrom(WordPair startPair, Random random) { if (random == null) { throw new ArgumentNullException(nameof(random)); } var state = _chain.FindState(StateType.Value, startPair); return(GenerateSentenceFromState(state >= 0 ? state : _beginMarker, random)); }
/// <summary> /// Generates a random sentence which starts with a particular word. /// If the generator does not know about the word, then a random word will be chosen. /// </summary> /// <param name="startWord">The word to start with.</param> /// <param name="random">The random number generator.</param> /// <returns>The words in the sentence.</returns> public IEnumerable <string> GenerateSentenceFrom(string startWord, Random random) { var state = _chain.FindState(StateType.Value, startWord); return(GenerateSentenceFromState(state >= 0 ? state : _beginMarker, random)); }