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): "); 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); }
static void Main(string[] args) { Chain chain = new Chain(); string[] input = File.ReadAllLines("TrumpTweets.txt"); string[] FormattedInput = Format.Tweets(input); foreach (string tweet in FormattedInput) { chain.AddString(tweet); } //update all the probabilities with the new data chain.UpdateProbabilities(); while (true) { string word = chain.GetRandomStartingWord(); String nextWord = chain.GetNextWord(word); Console.Write(word); while (nextWord != "") { Console.Write(" " + nextWord); nextWord = chain.GetNextWord(nextWord); } Console.ReadLine(); Console.WriteLine(); } }
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 Text Generator!"); /* * Console.WriteLine("Enter some text I can learn from (enter single ! to finish): "); * * while (true) * { * * Console.Write("> "); * * String line = Console.ReadLine(); * if (line == "!") * break; * * chain.AddString(line); // Let the chain process this string * } */ string[] lines = File.ReadAllLines(@"Files/Script.txt"); foreach (String s in lines) { chain.AddString(s); } // 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 output = ""; String word = Console.ReadLine(); while (true) { output += word + " "; word = chain.GetNextWord(word); if (word == "") { break; } } output = output.Trim(); output = output.Substring(0, 1).ToUpper() + output.Substring(1) + "."; Console.WriteLine(output); }
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): "); const Int32 BufferSize = 128; using (var fileStream = File.OpenRead(@"C:\Users\eahscs\Desktop\Text.txt")) using (var streamReader = new StreamReader(fileStream, Encoding.UTF8, true, BufferSize)) { String line; while ((line = streamReader.ReadLine()) != null) { // Process line chain.AddString(line); } } // 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 = chain.GetRandomStartingWord(); String nextWord = chain.GetNextWord(word); Console.WriteLine("Starting Word: " + word); Console.WriteLine("I predict the next word will be " + nextWord); while (nextWord != "") { // String newWord = nextWord; nextWord = chain.GetNextWord(nextWord); //nextWord = newWord; Console.WriteLine(nextWord); //dd } }
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 Marky Markov's Random Text Generator!"); Console.WriteLine("Enter some text I can learn from (enter a period(!) 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 generate a sentence."); Console.Write("> "); String word = chain.startingwords[0]; Console.WriteLine(chain.GenerateSentence(word)); String word2 = Console.ReadLine(); String nextWord3 = chain.GetNextWord(word); Console.WriteLine("I predict the next word will be " + nextWord3); }
static void Main(string[] args) { Random rand = new Random(System.Environment.TickCount); 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): "); * * while (true) * { * * Console.Write("> "); * * String line = Console.ReadLine(); * if (line == "!") * break; * * chain.AddString(line); // Let the chain process this string * }*/ string[] lines = File.ReadAllLines(@"Text\Minecraft.txt"); foreach (String line in lines) { String line2 = new string(line.Where(c => !char.IsPunctuation(c)).ToArray()); chain.AddString(line2.ToLower()); } // Now let's update all the probabilities with the new data chain.UpdateProbabilities(); // Okay now for the fun part //Console.WriteLine("Done learning! Now type in 10 words seperated by spaces, and I'll generate a minecraft parody."); //Console.Write("> "); //string[] startWords = Console.ReadLine().Split(' '); //Console.WriteLine(); /*for (int i = 0; i < startWords.Length; i++) * { * string nextWord = startWords[i]; * string New = nextWord; * New = New.Substring(0, 1).ToUpper() + New.Substring(1); * Console.Write(New + " "); * while (true) * { * nextWord = chain.GetNextWord(nextWord); * * if (nextWord == "") * break; * * Console.Write(nextWord + " "); * * } * Console.WriteLine(); * } */ Dictionary <String, List <String> > lyrics = new Dictionary <string, List <string> >(); for (int i = 0; i < 1000; i++) { string line = ""; string nextWord = chain.GetRandomStartingWord(); string New = nextWord; string lastWord = ""; New = New.Substring(0, 1).ToUpper() + New.Substring(1); line = New + " "; while (true) { lastWord = nextWord; nextWord = chain.GetNextWord(nextWord); if (nextWord == "") { break; } line += nextWord + " "; } List <String> list; if (lyrics.ContainsKey(lastWord)) { list = lyrics[lastWord]; list.Add(line); } else { list = new List <string>(); list.Add(line); lyrics.Add(lastWord, list); } } List <String> song = new List <String>(); int step = 0; for (int i = 0; i < 20; i++) { String key = lyrics.Keys.ElementAt(rand.Next() % lyrics.Keys.Count); if (lyrics[key].Count == 1) { i--; continue; } int first = rand.Next(lyrics[key].Count); int second = first; while (first == second) { second = rand.Next(lyrics[key].Count); } if (step == 1) { song.Insert(song.Count - 1, lyrics[key][first]); } else { song.Add(lyrics[key][first]); } song.Add(lyrics[key][second]); step++; if (step == 2) { step = 0; } } foreach (String s in song) { Console.WriteLine(s); } }
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"); } }
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): "); bool going = true; while (going == true) { int counter = 0; string line; // Read the file and display it line by line. System.IO.StreamReader file = new System.IO.StreamReader("TextFile1.txt"); while ((line = file.ReadLine()) != null) { //System.Console.WriteLine(line); if (line == "!") { going = false; } chain.AddString(line); // Let the chain process this string counter++; } file.Close(); } // Now let's update all the probabilities with the new data chain.UpdateProbabilities(); // Okay now for the fun part String word = chain.GetRandomStartingWord(); while (true) { //Console.WriteLine("Done learning! Now give me a word and I'll tell you what comes next."); //Console.Write("> "); String nextWord = chain.GetNextWord(word); Console.Write(" " + nextWord); if (nextWord.Contains(".") || nextWord.Contains("!") || nextWord.Contains("?")) { Console.WriteLine("\n"); word = chain.GetRandomStartingWord(); } else { word = nextWord; } if (word == "peckish") { break; } } }