paint-brush
Automated text generator using Markov Chainby@pubs
22,113 reads
22,113 reads

Automated text generator using Markov Chain

by Pubs AbayasiriJune 17th, 2017
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Making computer generated text mimic human speech using Markov Chain is a fascinating and actually not that difficult for an effect that is sometimes convincing, but certainly entertaining. Markov Chains work by generating sentences based on recombination of elements of history of known sentences to generate meaningful sentences.

Company Mentioned

Mention Thumbnail

Coin Mentioned

Mention Thumbnail
featured image - Automated text generator using Markov Chain
Pubs Abayasiri HackerNoon profile picture

See this step by step guide on how the algorithm works with reference code provided.

Photo by Thomas Lefebvre on Unsplash

Making computer generated text mimic human speech using Markov Chain is a fascinating and actually not that difficult for an effect that is sometimes convincing, but certainly entertaining. Markov Chains work by generating sentences based on recombination of elements of history of known sentences to generate meaningful sentences.

What’s really interesting, is that you can combine texts from two different people and get a mixed “voice”.

I played around this with texts of speeches from two great presidents:

Image of courtesy of screentv.com

What my text generator came up with from Obama speeches and Bartlet scripts, is as follows:

  • ‘Can I burn my mother in North Carolina for giving us a great night planned.’
  • ‘And so going forward, I believe that we can build a bomb into their church.’
  • ‘’Charlie, my father had grown up in the Situation Room every time I came in.’’
  • ‘This campaign must be ballistic.’,

Further details and the python source code

You can find a detailed explanation of how it works and also how to create one yourself at DrMysterian.com site: How to code a Markov Text Generator.

Otherwise, you can find the source code here.

Thanks for reading! If you like what you read, give a clap below so that others may find this (you can also find me on Twitter )