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!
pip3 install remarkov
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 ..."
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/*"