private string _InternalGenerate(string start, StopCriterion crit, int limit)
        {
            string        w1 = start.ToLower();
            StringBuilder sb = new StringBuilder();

            sb.Append(start.Capitalize());

            int    consecutiveNewLines = 0;
            string word      = null;
            string priorWord = null;

            // About the stop criteria:
            // we keep going til we reach the specified number of words or chars, with the added
            // proviso that we have to complete the in-flight sentence when the limit is reached.

            for (int i = 0;
                 (crit == StopCriterion.NumberOfWords && i < limit) ||
                 (crit == StopCriterion.NumberOfChars && sb.Length < limit) ||
                 consecutiveNewLines == 0;
                 i++)
            {
                if (table.ContainsKey(w1))
                {
                    var list = table[w1];
                    int ix   = rnd.Next(list.Count);
                    priorWord = word;
                    word      = list[ix];
                    if (word != "\n")
                    {
                        // capitalize
                        if (consecutiveNewLines > 0)
                        {
                            sb.Append(word.Capitalize());
                        }
                        else
                        {
                            sb.Append(" ").Append(word);
                        }

                        // words that end sentences get a newline
                        if (word.EndsWith("."))
                        {
                            if (consecutiveNewLines == 0 || consecutiveNewLines == 1)
                            {
                                sb.Append("\n");
                            }
                            consecutiveNewLines++;
                        }
                        else
                        {
                            consecutiveNewLines = 0;
                        }
                    }
                    w1 = word.ToLower().TrimPunctuation();
                }
            }
            return(sb.ToString());
        }
        private string _InternalGenerate(string start, StopCriterion crit, int limit)
        {
            string w1 = start.ToLower();
            StringBuilder sb = new StringBuilder();
            sb.Append(start.Capitalize());

            int consecutiveNewLines = 0;
            string word = null;
            string priorWord = null;

            // About the stop criteria:
            // we keep going til we reach the specified number of words or chars, with the added
            // proviso that we have to complete the in-flight sentence when the limit is reached.

            for (int i = 0;
                 (crit == StopCriterion.NumberOfWords && i < limit) ||
                     (crit == StopCriterion.NumberOfChars && sb.Length < limit) ||
                     consecutiveNewLines == 0;
                 i++)
            {
                if (table.ContainsKey(w1))
                {
                    var list = table[w1];
                    int ix = rnd.Next(list.Count);
                    priorWord = word;
                    word = list[ix];
                    if (word != "\n")
                    {
                        // capitalize
                        if (consecutiveNewLines > 0)
                            sb.Append(word.Capitalize());
                        else
                            sb.Append(" ").Append(word);

                        // words that end sentences get a newline
                        if (word.EndsWith("."))
                        {
                            if (consecutiveNewLines == 0 || consecutiveNewLines == 1)
                                sb.Append("\n");
                            consecutiveNewLines++;
                        }
                        else consecutiveNewLines = 0;
                    }
                    w1 = word.ToLower().TrimPunctuation();
                }
            }
            return sb.ToString();
        }