Skip to main content

A toy Markov chain implementation.

Project description

Vokram is a toy Markov chain library that is most likely implemented incorrectly and extremely inefficiently.

Installation

Use pip to install:

pip install vokram

Usage

Command Line Usage

Pipe a body of text into vokram and it will generate some (hopefully) plausible sentences synthesized from that body of text:

$ cat the_art_of_war.txt | vokram
Spies cannot be obtained inductively from experience, nor by any danger.

You can control the maximum number of words in the output and the n-gram size used when building the Markov model. All command line options are given below:

$ vokram --help

Outputs:

usage: vokram [-h] [-w NUM_WORDS] [-n NGRAM_SIZE]

Generates plausible new sentences from a corpus provided on STDIN.

optional arguments:
  -h, --help            show this help message and exit
  -w NUM_WORDS, --num-words NUM_WORDS
                        Maximum number of words in the resulting sentence.
  -n NGRAM_SIZE, --ngram-size NGRAM_SIZE

Library Usage

Vokram can also be used as a plain old Python library:

>>> import vokram
>>> corpus = open('the_art_of_war.txt')
>>> model = vokram.build_word_model(corpus, 2)
>>> vokram.markov_words(model, 25))
'Hence it is not supreme excellence; supreme excellence consists in breaking the enemy's few.'

Credits

Vokram was made with inspiration from this simple and approachable Python implementation and explanation.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vokram-1.0.0.tar.gz (5.8 kB view details)

Uploaded Source

File details

Details for the file vokram-1.0.0.tar.gz.

File metadata

  • Download URL: vokram-1.0.0.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for vokram-1.0.0.tar.gz
Algorithm Hash digest
SHA256 e9403c5b21d09fa791e03a602c83305f067e42cddc96b6069bdc6260043fa23c
MD5 b6e94241ac860bd1fa1540b0e40e6047
BLAKE2b-256 dd566893d2521a1c2a30e861d8a81af997d9624f2e73276e32a98ce040c1692d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page