Overview
The markov topic provides word-level Markov chain text generation. A Markov chain model
learns transition probabilities between words from a source corpus, then uses those probabilities to
generate plausible continuations of a given input text.
The trained model is persisted to a .Markov subfolder relative to the current working
directory. Train the model once from a corpus, then call complete as many times as needed.
.Markov/ relative to the current working directory.
Run both train and complete from the same directory to use the same model.
train
Trains a Markov chain model from a source text file. The model records word-to-word transition
probabilities across the entire corpus. The trained model is saved to the .Markov/
subfolder in the current working directory, replacing any previously trained model.
On success, the number of unique transition words in the model is reported to stdout.
| Option | Required | Description |
|---|---|---|
--source | Yes | Path to the source text file to train from |
complete
Generates a text completion by extending the provided seed text using the trained Markov chain model.
The model must have been trained with markov train first.
The seed text is used to find a starting point in the model; generation then follows learned
transition probabilities word by word.
| Option | Required | Default | Description |
|---|---|---|---|
--text | Yes | — | Seed text to start the completion from |
--count | No | 50 | Number of words to generate |
Command Reference
| Command | Required options | Optional options | Output |
|---|---|---|---|
markov train |
--source |
— | Success message with unique word count to stdout |
markov complete |
--text |
--count |
Generated text to stdout |