/// <summary>
        /// Creates a sentence generator which is backed by a Markov chain.
        /// </summary>
        /// <param name="chain">The chain to use. It may be mutated by the generator.</param>
        public Order1SentenceGenerator(IMarkovChain <string> chain)
        {
            _chain = chain;

            // Create marker states which represent the beginning and end of a sentence
            _beginMarker = _chain.FindOrCreateState(StateType.Marker, BeginMarkerName);
            _endMarker   = _chain.FindOrCreateState(StateType.Marker, EndMarkerName);
        }
Beispiel #2
0
        /// <summary>
        /// Creates a sentence generator which is backed by a Markov chain.
        /// </summary>
        /// <param name="chain">The chain to use. It may be mutated by the generator.</param>
        public Order2SentenceGenerator(IMarkovChain <WordPair> chain)
        {
            if (chain == null)
            {
                throw new ArgumentNullException(nameof(chain));
            }

            _chain = chain;

            // Create marker states used to represent the beginning and end of a sentence
            _beginMarker = _chain.FindOrCreateState(StateType.Marker, BeginMarkerPair);
            _endMarker   = _chain.FindOrCreateState(StateType.Marker, EndMarkerPair);
        }
 private int FindOrCreateWord(string word)
 {
     return(_chain.FindOrCreateState(StateType.Value, word));
 }
Beispiel #4
0
 private int GetOrCreatePair(string word1, string word2)
 {
     return(_chain.FindOrCreateState(StateType.Value, new WordPair(word1, word2)));
 }