Skip to main content

Another text generator based on Markov chains.

Project description

Installation

Using pip:

  • pip3 install markovgen –user

Or

From the git repository:

Command-line usage

Usage:

python3 -m markovgen <extracter> <path to log file>

Supported extracters are:

  • supybot

  • weechat

  • xchat

Usage as a library

markovgen.Markov:
__init__(messages=[]):

takes an optional list of initial messages.

feed(message):

takes a message and adds it to the cache.

feed_from_file(file_descriptor, extracter):

Reads the file descriptor line by line, apply the extracter to it, and feeds the cache with the return value of the extracter.

generate_markov_text(max_size=30, seed_word=None, backward=False):

Generate a text based on the cache. Selects a random word in the cache as the first (resp. last) word, and continues forward (resp. backward) using the cache in the right direction, until it selects a message end from the cache or that the max_size is met.

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

markovgen-0.2.5.tar.gz (3.0 kB view hashes)

Uploaded Source

Supported by

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