Another text generator based on Markov chains.
Project description
Installation
Using pip:
pip3 install markovgen –user
Or
From the git repository:
git clone https://github.com/ProgVal/markovgen.git
cd markovgen
python3 setup.py install –user
Command-line usage
- Usage:
python3 -m markovgen <extracter> <path to log file>
Supported extracters are:
srt
supybot
weechat
xchat
plain
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=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. The seed may be a string or a 2-tuple of strings.
- available_seeds(backward=False):
Returns a view on the 2-tuples of words in the corpus. Useful if you want to match them against a new message.
- @mixed_encoding_extracting:
decorator for extracters that handle decoding messages with the right charset (if chardet or charade is installed) or as utf8 (otherwise)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file markovgen-0.5.tar.gz
.
File metadata
- Download URL: markovgen-0.5.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 74b09cca0cab95369872aa9a6c02b8c6e51e503b413d25db39dfeb54ca14b65b |
|
MD5 | 26e204032c5f5a774537371b68116d9a |
|
BLAKE2b-256 | 0f93f00647407e262d56c9eafc446b3227f2bc65e9477f98ef3777533625b5f8 |