Giter VIP home page Giter VIP logo

markov-generator's Introduction

Markov-Generator

Generate pseudo-random texts using Markov chains as input.

Using from shell

A convenience script is provided. Pass the files you want to use a learn experience, and the script will read them and generate a sentence.

    $ php markov.php FILE1 FILE2 ....

Using from php

The API is dead simple: first train, then generate.

$markov = new MarkoGenerator();

// train the model
foreach (trainSet() as $sentence)
    $markov->learn($sentence);

// generate a 5-words length sentence
echo $markov->generate(5);

Shakespeare Sonet

This sonet was generated using Shakespeare's Sonets 140 to 157 as trainning input.

The likeness of a man,
Or if they have, where is my sin, grounded on
Not, then love doth well denote,
Words, and words express
Random from the truth vainly expressed:
Give the lie to my love,
View is pleased to dote.
Why of two oaths' breach do I accuse thee,
Whilst her neglected child holds her in chase,
Sees not till heaven clears.
With others thou shouldst not abhor my state.
Spirit a woman coloured ill.
  On that which longer nurseth the disease,
  Triumph in love; flesh stays no farther reason.

To generate another pseudo-random sonet, take a look at the example folder, or simply run:

$ php examples/shakespeare.php

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.