PHPackages                             andreskrey/shitty-markov-generator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. andreskrey/shitty-markov-generator

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

andreskrey/shitty-markov-generator
==================================

A shitty implementation to generate Markov chains to create incoherent phrases.

022PHP

Since Aug 25Pushed 9y ago1 watchersCompare

[ Source](https://github.com/andreskrey/ShittyMarkovGenerator)[ Packagist](https://packagist.org/packages/andreskrey/shitty-markov-generator)[ RSS](/packages/andreskrey-shitty-markov-generator/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

ShittyMarkovGenerator
=====================

[](#shittymarkovgenerator)

A shitty implementation of the Markov chains
--------------------------------------------

[](#a-shitty-implementation-of-the-markov-chains)

### What?

[](#what)

If you take a text, explode it, and then inspect the words, you'll see that some words appear more often next to some other words. Sometimes words appear next to each other rarely. If you explore that relations and assign a score to each relation, you can use this information to create phrases that will have a correct structure and, hopefully, some meaning. This exploration task is, in a super simplified way, Markov chains.

This project will create phrases based on the texts that you feed it. In a way, the bigger the text, the "smarter" the phrase it will generate.

### How?

[](#how)

When you feed a text to the Chainer function, it will explode all the words and create a dictionary, assigning a specific score to each word and the next one, based on repetition.

Then it will output a phrase based on that dictionary. You can select the chain size (lenght of the phrase), the topic (it will try to match the topic you define with a word in the dictionary and start the phrase from there) and the block size (the way the dictionary will be constructed).

### Usage

[](#usage)

You can use it either by CLI or as a dependency. Download the project and use `composer install` to generate the autoloader.

Otherwise just run it by CLI.

`php chainer.php -r /path/to/your/text`

The example text can be anything. Just make sure it's long enough to create interesting phrases.

### Why is it better than other Markov generators out there?

[](#why-is-it-better-than-other-markov-generators-out-there)

What I like about my project is that it doesn't select words randomly. The other projects I saw, selected the word from the pool with a random function. In this project, words are selected by chances. When the dictionary is constructed, a score is assigned to the following possible word. At the moment of selecting a new word, if there is more than one option, those options will be selected by random, but those words that naturally have more chances to appear next to the selected one will be selected more often. Check the `createChances` function on the markovBot file to understand it better.

It also tries to end the phrase in a punctuation mark. This doesn't work perfectly, but given the right conditions, it will give you a phrase that ends in `!`, `.` or `?`.

### Bugs

[](#bugs)

- Block size is tricky right now. If you select a bigger block size than 2, it will repeat itself when generating phrases. When a word is selected, the previous block is deleted from the dictionary to avoid repetition, but because of the way the dictionary is generated, similar combinations are still present on it.

### Acknowledgements

[](#acknowledgements)

This project is heavily based on the [markov-php](https://github.com/heidilabs/markov-php/) project by [heidilabs](https://github.com/heidilabs).

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/8786949?v=4)[Andres Rey](/maintainers/andreskrey)[@andreskrey](https://github.com/andreskrey)

---

Top Contributors

[![andreskrey](https://avatars.githubusercontent.com/u/8786949?v=4)](https://github.com/andreskrey "andreskrey (10 commits)")

### Embed Badge

![Health badge](/badges/andreskrey-shitty-markov-generator/health.svg)

```
[![Health](https://phpackages.com/badges/andreskrey-shitty-markov-generator/health.svg)](https://phpackages.com/packages/andreskrey-shitty-markov-generator)
```

###  Alternatives

[typo3/cms-scheduler

TYPO3 CMS Scheduler - Schedule tasks to run once or periodically at a specific time.

169.3M210](/packages/typo3-cms-scheduler)[plesk/pm-api-stubs

Plesk Extensions API PHP files stubs for IDE.

2546.4k1](/packages/plesk-pm-api-stubs)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
