2017 © Pedro Peláez
 

library markov-php

A simple markov chain experiment

image

heidilabs/markov-php

A simple markov chain experiment

  • Wednesday, August 19, 2015
  • by erikaheidi
  • Repository
  • 3 Watchers
  • 11 Stars
  • 1,042 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 7 Forks
  • 3 Open issues
  • 6 Versions
  • 7 % Grown

The README.md

markov-php

Warning: this project is highly experimental., (*1)

Usage

Just clone and run composer install to create the autoloader. Not necessary if you just want to use the CLI script., (*2)

Using the Library in your Project

markov-php is available on Packagist for installation through Composer. heidilabs/markov-php, (*3)

    $ composer require heidilabs/markov-php "~0.2"

Demos

Word Chain

CLI:, (*4)

    $ php chainer.php -r demos/resources/mobydick.txt

example output:, (*5)

to cast anchor in the deep; for heavy chains are being dragged along the cycloid, my soapstone for example, will, (*6)

Script:, (*7)

    <?php

    require_once(__DIR__ . '/../vendor/autoload.php');

    $sample = file_get_contents(__DIR__ . '/resources/nietzsche.txt');

    $chain = new MarkovPHP\WordChain($sample, 2);
    $sentence = $chain->generate(10);

    echo "YOUR PIECE OF WISDOM FROM NIETZSCHE<br><br>";
    echo $sentence;

example output:, (*8)

must be contrary to their pride, and also more mysterious, than one thinks: the capable man in the purity of his character, (*9)

Word Chain - Theme

CLI:, (*10)

    $ php chainer.php -r demos/resources/mobydick.txt -t love

example output:, (*11)

love of neatness in seamen; some of whom would not have that ferule and buckle-screw; I'll be ready for them, (*12)

    <?php
    require_once(__DIR__ . '/../vendor/autoload.php');

    $sample = file_get_contents(__DIR__ . '/resources/nietzsche.txt');

    $chain = new MarkovPHP\WordChain($sample, 2);
    $theme = "hate";
    $sentence = $chain->generate(10, $theme);

    echo "YOUR PIECE OF WISDOM FROM NIETZSCHE, ABOUT: $theme<br><br>";
    echo $sentence;

example output:, (*13)

they hate thee, and me, and half-and-half, and impure!-- Ah, I cast hail-showers into the depths. Violently will my breast then heave;, (*14)

Mixed Source

Combines two different sources and creates a simple chain with two connected parts:, (*15)

    <?php
    require_once(__DIR__ . '/../vendor/autoload.php');

    $sample1 = file_get_contents(__DIR__ . '/resources/nietzsche.txt');
    $sample2 = file_get_contents(__DIR__ . '/resources/mobydick.txt');

    $chain = new \MarkovPHP\MixedSourceChain($sample1, $sample2);
    $sentence = $chain->generate();

    echo "RESULT:<br>";
    echo $sentence;

example output:, (*16)

do so, proves that he is probably not only strong, she keeps so many moody secrets. The schools composing none, (*17)

The Versions

19/08 2015

dev-master

9999999-dev https://github.com/heidilabs/markov-php

A simple markov chain experiment

  Sources   Download

MIT

markov

19/08 2015

dev-erikaheidi-patch-1

dev-erikaheidi-patch-1 https://github.com/heidilabs/markov-php

A simple markov chain experiment

  Sources   Download

MIT

markov

04/06 2015

0.4

0.4.0.0 https://github.com/heidilabs/markov-php

A simple markov chain experiment

  Sources   Download

MIT

markov

04/06 2015

0.3

0.3.0.0 https://github.com/heidilabs/markov-php

A simple markov chain experiment

  Sources   Download

MIT

markov

14/02 2015

0.2

0.2.0.0 https://github.com/heidilabs/markov-php

A simple markov chain experiment

  Sources   Download

MIT

markov

17/12 2014

0.1

0.1.0.0 https://github.com/heidilabs/markov-php

A simple markov chain experiment

  Sources   Download

MIT

markov