PyCon Pittsburgh. April 15-23, 2020.

Talk: Pyambic Pentameter: generating rhyming and metered poems with Markov chains and NLTK

Presented by:

Kathryn Lingel


a strategy to generate a rhyme / without a human spending any time

Computers may not yet be able to write poetry with soul, but we can teach them to write poetry with style! By combining Markov chain random text generation with a pronunciation dictionary in Python’s Natural Language ToolKit (NLTK), we can generate a poem that has both rhyme and meter.

Random text generation is a fun, beginner-friendly project with a lot of potential depth for the curious and creative. This talk will cover how to generate random writing based on a source text, as well as how to use NLTK to enhance the output, and conclude with a brand new Shakespearean sonnet!


Watch on YouTube