Giter Club home page Giter Club logo

generating-poems-with-markov-chains's Introduction

An attempt at generating poems using Markov Chains

I used poem collections from Project Gutenberg to train both a first order and second order Markov Chain model. This was done in Java. I then extracted the transition probabilities to JSON format for the demo. Using words's javascript rhyming library, I'm able to determine which words rhyme with the last word on some line, so we can do a depth first search using the transition probabilities from the markov chain model to find a path (a sentence) to a word that rhymes with the last word on some other line.

Example poem

this child of his eyes the
same they said is king so the good
man thought twere pity he should
have kept nigh half the time
of nor ask for has lime
in sight clear as heaven may
man put on defeat as t were a day
and show that this is today
a can experiment is that conquers
might with dian ear make bold
to scorn and as she wills with carpets of gold
and blithe fair face ye are
mad ye have gone acrosst the bar
of seas far away and more
than one close joy i see before

How to use

Demo available at https://marcusgh.github.io/poem-generator/main.html. Click the "Next Line" button to generate a line of poetry.

generating-poems-with-markov-chains's People

Contributors

marcusgh avatar

Watchers

 avatar  avatar

generating-poems-with-markov-chains's Issues

Better sentences

Use full stops in training data to determine where sentences stop. Start a new sentence whenever another one stops.

Improve the UI design

Improve the UI by adding

  • basic CSS
  • Explanations (as tooltips) for the different sliders
  • Credits

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.