Giter Site home page Giter Site logo

markov's Introduction

markov

MarkovModel.java creates a Markov model of order k based on a given input text. For each group of consecutive k characters in the input text (called a k-gram), we generate the probability that any individual character will appear after that k-gram.

TextGenerator.java uses MarkovModel to repeatedly generate probabilistic next characters for a total length T. For example, using the input file beatles.txt (not included; any text file may be substituted), which contains lyrics from popular Beatles songs,

% more beatles.txt
Words are flowing out like endless rain into a paper cup, They slither while they pass, they slip
away across the universe. Pools of sorrow waves of joy are drifting through my opened mind,
Possessing and caressing me. Jai guru deva om Nothing's gonna change my world Nothing's
gonna change my world. Nothing's gonna change my world Nothing's gonna change my world.
Images of broken light which dance before me like a million eyes, They call me on and on across
the universe, Thoughts meander like a restless wind Inside a letter box they Stumble blindly as
they make their way Across the universe Jai guru deva om Nothing's gonna change my world

running TextGenerator 5 200 < beatles.txt yields a model of order k=5 and generates T=200 characters in the linguistic style of the Beatles. It might look like this:

Words are flowing of Marigold way. I've been us instead. Please don't you want you don't do you, yeh, All my love. Oh dearest one, if you I adore. When your birthday to
you. (sha la la la la la la la 

Or this:

Words are drifting and seen searchin' for this money? Sonny, if you walk away. One, two, three, girls read and I dream will
see her walk about you walk around, yeh, It took me on
out. Daylight now ove

In general, larger k tends to reproduce more of the input text.

markov's People

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.