Chattymarkov
Description
Chattymarkov is a python module that lets you generate random sentences through a markov chain algorithm.
It is useful mostly for bots which are aimed at learning from user’s chat and generate totally w.t.f. answers.
The library can support multiple databases, especially redis which is quite suitable to store relevant information for markov chains.
Installation
pip install chattymarkov
Examples
From examples/memory.py
#!/usr/bin/env python3
from chattymarkov import ChattyMarkov
markov = ChattyMarkov("memory://")
markov.learn("My favorite animal is the crocodile")
markov.learn("The word animal is six letters long")
print(markov.generate())
Here the markov instance learns two sentences (presumably gathered from a chat network such as IRC or Discord). What is interesting is that the ‘animal is’ sequence appears twice. So the generate() method, which returns a completely random result, may return an entirely built sentence which hasn’t been ever written by anyone:
$ ./memory.py
The word animal is the crocodile
$ ./memory
My favorite animal is six letters long
The more sentences, the funnier generated ones.
Supported databases
Redis (recommended): you can either provide a unix socket path (e.g. redis:///path/to/unix_socket.sock;db=0;password=foobar or an URL (e.g redis://user:password@localhost:6739/0). For the async version, either use redis_async:// or instantiate a ChattyMarkovAsync instance.
JSON: you can provide a path to a file that will be formated with JSON. Example: json:///path/to/file.json
Memory: in-memory database, just provide memory:// as a connect string. For the async version, use memory_async:// instead.
Contribute
If you want to add some support to a database or redesign the library, please make a pull request so we can discuss about it.
Todo
Support other databases?
Metadata
Release files for chattymarkov 1.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| chattymarkov-1.3.0.tar.gz | 8.7 kB | Without provenance | Details for chattymarkov-1.3.0.tar.gz |
Release files / chattymarkov-1.3.0.tar.gz
| Download URL | chattymarkov-1.3.0.tar.gz |
|---|---|
| Size | 8.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6e67b99d735a3dbfc1013d2a14164d5b432bcef664cddb74252d6ff43fbd0695
|
|
BLAKE2b-256 checksum How to use checksums |
7bce26288b27f08240eae518f0691c0d1bbcb077f528b57256340ab30d41390a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5
|
Security for chattymarkov 1.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.