コード例 #1
0
        private IEnumerable <string> GenerateSentenceFromState(int startState, Random random)
        {
            var currentState = startState;

            while (currentState != _endMarker)
            {
                if (currentState != _beginMarker)
                {
                    yield return(_chain.GetValue(currentState));
                }
                if (!_chain.GetRandomNextState(currentState, random, out currentState))
                {
                    break;
                }
            }
        }
コード例 #2
0
        private IEnumerable <string> GenerateSentenceFromState(int startState, Random random)
        {
            var    currentState = startState;
            string lastWord     = null;

            while (currentState != _endMarker)
            {
                if (currentState != _beginMarker)
                {
                    var val = _chain.GetValue(currentState);
                    lastWord = val.Second;
                    yield return(val.First);
                }
                if (!_chain.GetRandomNextState(currentState, random, out currentState))
                {
                    break;
                }
            }
            if (lastWord != null)
            {
                yield return(lastWord);
            }
        }