Generate text from text using Markov chains.
Project description
ReMarkov is a Python library for generating text from existing samples using Markov chains. You can use it to customize all sorts of writing from birthday messages, horoscopes, Wikipedia articles, or the utterances of your game's NPCs. Everything works without an omnipotent "AI" - it is dead-simple code and therefore fast.
Check out the examples and feel free to contribute!
Installation
pip3 install remarkov
Example
Scrape the Wikipedia page for "Computer Programming" and generate a new text from it:
./tools/scrape-wiki.py Computer_programming | remarkov build | remarkov generate
You can also use remarkov programmatically:
from remarkov import create_model
model = create_model()
model.add_text("This is a sample text and this is another.")
print(model.generate().text())
# "This is a sample text and this is a sample text and this is a sample text ..."
Development
Make sure you run pytest as module. This will add the current directory to the import path:
python3 -m pytest
This project uses black for source code formatting:
black .
Generate documentation for the project (this uses the original pdoc at pdoc.dev):
git checkout gh-pages
pdoc -t pdoc/template -o public/docs <path_to_remarkov_module>
Run type checks using mypy:
mypy -p remarkov
Publishing is done like this (don't forget to bump the version in setup.py):
pip3 install twine # optional
git tag -a <version>
git push --tags
python3 setup.py clean --all
python3 setup.py sdist bdist_wheel
twine check "dist/*"
twine upload "dist/*"
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file remarkov-0.2.6.tar.gz.
File metadata
- Download URL: remarkov-0.2.6.tar.gz
- Upload date:
- Size: 7.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
23e451ee5be39e105cebe537e58fb6dcc3d8f81167efaec6e42782c7035d61ac
|
|
| MD5 |
55488bcd5c3f1055a2d12bbb43b87986
|
|
| BLAKE2b-256 |
cb0e43b53fed157aba81da9e374f6989e12c9ca04c8160e3abec6277b0c4b931
|
File details
Details for the file remarkov-0.2.6-py3-none-any.whl.
File metadata
- Download URL: remarkov-0.2.6-py3-none-any.whl
- Upload date:
- Size: 22.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
22af98620ac40b352fa743213131da0f86636020dda339b6933d7cfef597ce28
|
|
| MD5 |
1bb31fdf15ace54681e777ec0d6cd4f4
|
|
| BLAKE2b-256 |
20115b2b55a6c8f17506093b2f98bb2c18f1b9dbc7dfa0c116c6e880dab4b49d
|