Python Markov Chain Generator - Printable Version +- Forums - Open Redstone Engineers (https://forum.openredstone.org) +-- Forum: Off-Topic (https://forum.openredstone.org/forum-4.html) +--- Forum: Programming (https://forum.openredstone.org/forum-8.html) +--- Thread: Python Markov Chain Generator (/thread-6846.html) |
Python Markov Chain Generator - ddthj - 06-25-2015 So I spent 3 hours making a messy markov chain generator in python, and since it was a pain to do I figured I'd post it here so no one else has to go through the trouble This takes a text input prompt but you could use any method to give it text. The generator keeps track of: words, what words come after other words, the amount of times a word has come after another word. Brain format: brain{ word :[ [other word, times found], [other word, times found] ], word :[ [other word, times found], [other word, times found] ] } kindof a mess, but hey if it works it works :) Code: brain = {} #making the main dict RE: Python Markov Chain Generator - Chibill - 06-25-2015 And what good is this? RE: Python Markov Chain Generator - ddthj - 06-25-2015 (06-25-2015, 08:22 AM)Chibill Wrote: And what good is this? I't mostly used for taking a bunch of text (like a book) and generating sentences that are sometimes cohesive. I can also be used to find variations in writing style or topic. |