Exemple #1
0
        static void Main(string[] args)
        {
            Chain chain = new Chain();

            Console.WriteLine("Welcome to Marky Markov's Random Text Generator!");
            Console.WriteLine();
            LoadText("Sample.txt", chain);

            /*
             * while (true)
             * {
             *
             *  Console.Write("> ");
             *
             *  String line = Console.ReadLine();
             *  if (line == "!")
             *      break;
             *
             *  chain.AddString(line);  // Let the chain process this string
             * }
             */
            // Now let's update all the probabilities with the new data
            chain.UpdateProbabilities();

            // Okay now for the fun part


            String word = chain.startingwords[0];

            for (int i = 0; i < 6000; i++)
            {
                Console.WriteLine(chain.GenerateSentence(word));
            }
        }
        static void Main(string[] args)
        {
            Chain chain = new Chain();

            Console.WriteLine("Welcome to Marky Markov's Random Text Generator!");

            Console.WriteLine("Enter some text I can learn from (enter single ! to finish): ");

            // LoadText("Sample.txt", chain);

            while (true)
            {
                Console.Write("> ");

                String line = Console.ReadLine();
                if (line == "!")
                {
                    break;
                }

                chain.AddString(line);  // Let the chain process this string
            }

            // Now let's update all the probabilities with the new data
            chain.UpdateProbabilities();

            // Okay now for the fun part
            Console.WriteLine("Done learning!  Now give me a word and I'll tell you what comes next.");
            Console.Write("> ");

            String startingWord = Console.ReadLine();
            String nextWord     = chain.GenerateSentence(startingWord);

            Console.WriteLine("I predict the next word will be " + GenerateSentence);
        }
        static void Main(string[] args)
        {
            Chain chain = new Chain();

            Console.WriteLine("Welcome to Marky Markov's Random Text Generator!");

            Console.WriteLine("Enter some text I can learn from (enter single ! to finish): ");

            //LoadText("Sample.txt", chain);

            while (true)
            {
                Console.Write("> ");

                String line = Console.ReadLine();
                if (line == "!")
                {
                    break;
                }

                chain.AddString(line);  // Let the chain process this string
            }

            // Now let's update all the probabilities with the new data
            chain.UpdateProbabilities();

            // Okay now for the fun part
            Console.WriteLine("Done learning!  Now give me a word and I'll tell you what comes next.");
            Console.Write("> ");

            String word     = Console.ReadLine();
            String nextWord = chain.GetNextWord(word);

            Console.WriteLine("I predict the next word will be " + nextWord);


            /*for (int i = 0; i < 10; i++)
             * {
             *  Console.WriteLine(chain.GenerateSentence(chain.GetRandomStartingWord()));
             * } */

            Console.WriteLine("Now I will generate some fun sentences!");


            Random random = new Random();
            int    count  = random.Next(1, 50);
            int    num    = 0;

            while (num < count)
            {
                Console.WriteLine(chain.GenerateSentence(chain.GetRandomStartingWord()));
                num++;
            }
        }
        static void Main(string[] args)
        {
            Chain chain = new Chain();

            Console.WriteLine("Welcome to Marky Markov's Random Insult Generator!");
            Console.WriteLine("");

            //Console.WriteLine("Enter some text I can learn from (enter single ! to finish): ");

            LoadText("Sample.txt", chain);

            /*while (true)
             * {
             *
             *  Console.Write("> ");
             *
             *  String line = Console.ReadLine();
             *  if (line == "!")
             *      break;
             *
             *  chain.AddString(line);  // Let the chain process this string
             * }
             *
             * Now let's update all the probabilities with the new data
             *
             * // Okay now for the fun part
             * Console.WriteLine("Done learning!  Now give me a word and I'll tell you what comes next.");
             * Console.Write("> ");
             *
             * String word = Console.ReadLine();
             * String nextWord = chain.GetNextWord(word);
             * Console.WriteLine("I predict the next word will be " + nextWord);*/

            chain.UpdateProbabilities();

            String word = chain.startingWords[0];

            for (int i = 0; i < 20; i++)
            {
                Console.WriteLine(chain.GenerateSentence(word));
            }
            Console.ReadLine();
        }
        static void Main(string[] args)
        {
            Chain chain = new Chain();

            Console.WriteLine("Welcome to Vinniehat's Markov Text Generator!");
            Console.WriteLine("	\t\n      .___.\n     /     \\\n    | O _ O |\n    /  \\_/  \\ \n  .' /     \\ `.\n / _|       |_ \\\n(_/ |       | \\_)\n    \\       /\n   __\\_>-<_/__\n   ~;/     \\;~");

            Console.WriteLine("To use this program, enter a sentence! After each sentence, hit enter. Once finished, type \"!\" on a new line!");

            LoadText("Sample.txt", chain);

            while (true)
            {
                Console.Write("> ");

                String line = Console.ReadLine();
                if (line == "!")
                {
                    break;
                }

                chain.AddString(line);  // Let the chain process this string
            }

            // Now let's update all the probabilities with the new data
            chain.UpdateProbabilities();

            // Okay now for the fun part
            Console.WriteLine("Done learning!  Now give me a word and I'll tell you what comes next.");
            Console.Write("> ");

            String word      = Console.ReadLine();
            String nextWord  = chain.GetNextWord(word);
            String sentence  = chain.GenerateSentence();
            String beginning = $"{word} {nextWord}";

            Console.WriteLine("Would you like to sentence(1) or paragraph(2)? ");
            var option = Console.ReadLine();

            if (option == "1")
            {
                Console.WriteLine("Generating Sentence... ");
                for (int i = 0; i <= 100; i++)
                {
                    Console.Write("\r{0}%", i);
                    Thread.Sleep(20);
                }
                Console.WriteLine("\nHere is your sentence: " + beginning + sentence);
            }
            else if (option == "2")
            {
                Console.WriteLine("Generating Paragraph... ");
                for (int i = 0; i <= 100; i++)
                {
                    Console.Write("\r{0}%", i);
                    Thread.Sleep(40);
                }
                String s1        = chain.GenerateSentence();
                String s1w       = chain.GetNextWord(word);
                String s2        = chain.GenerateSentence();
                String s2w       = chain.GetNextWord(word);
                String s3        = chain.GenerateSentence();
                String s3w       = chain.GetNextWord(word);
                String s4        = chain.GenerateSentence();
                String s4w       = chain.GetNextWord(word);
                String s5        = chain.GenerateSentence();
                String s5w       = chain.GetNextWord(word);
                String paragraph = $"{word} {s1w}{s1}. {word} {s2w}{s2}. {word} {s3w}{s3}. {word} {s4w}{s4}. {word} {s5w}{s5}.";
                Console.WriteLine("\nHere is your paragraph: ");
                Console.WriteLine("------------------------------");
                Console.WriteLine(paragraph);
            }
            else
            {
                Console.WriteLine("YOU ENTERED THE WRONG NUMBER!");
                Console.WriteLine("https://images.vinniehat.com/video/1");
                Console.WriteLine("https://images.vinniehat.com/video/1");
                Console.WriteLine("https://images.vinniehat.com/video/1");
                Console.WriteLine("https://images.vinniehat.com/video/1");
            }
        }