Skip to main content

Generate random words based on Markov chains

Project description

Gibi is a random word generator, based on Markov chains.

It analyzes a text in order to deduce the probability of transition from one character to another, and then generates a completely random word that will look alike what you have feeded it as input.

Build status

develop:

build-develop

master:

build-master

Usage

Gibi can be used either as a CLI tool, either as a library.

CLI

The very simple rand_word.py will analyze any text file, and generate a random word based on it.

$ rand_word.py french_cities.txt
jambous-dirchetomeilla

API

The best way to see how to use the API is to look how rand_word.py works:

with codecs.open(path, 'r', encoding='utf-8') as f:
    n = FrenchNormalizer(f)
    m = Matrix()

    m.feed(n)

print(m.make_word())

You can also make something deterministic by providing a seed to make_word(). Given the same Matrix and the same seed, you will always get the same result. The provided seed is anything that Python’s random would accept. See the following example:

assert m.make_word(42) == m.make_word(42)

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

gibi-0.1.1.tar.gz (4.9 kB view details)

Uploaded Source

File details

Details for the file gibi-0.1.1.tar.gz.

File metadata

  • Download URL: gibi-0.1.1.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for gibi-0.1.1.tar.gz
Algorithm Hash digest
SHA256 e72044b5397d56fef0e645e063ef04da94d2fd20f226d79b7648e18ba0a51101
MD5 81c3cf86b6a597193e779d5d91e70e60
BLAKE2b-256 55ec35be722110cc7e6ccb963a7c8f6bdfcba0fde47fb09032c25b8051bb3bbb

See more details on using hashes here.

Supported by

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