mc.py is a tiny and trivial Python package which provides you a simple way to generate phrases using Markov chains.
I think it is mostly just for fun. I know that some devs use this or similar packages/algorithms for chat-bots to generate funny messages (e.g. VK bot Witless or VK bot Sglypa). I used it to generate cringy gopnik-style quotes.
(It is complicated and absolutely optional, but quite interesting).
- Markov chain (Wikipedia)
- Markov model (Wikipedia)
- From "What is a Markov Model" to "Here is how Markov Models Work" (mc.py is in fact based on this article)
Just install it using pip or with any other package manager you use... Should I seriously teach you this?
pip install mc.py
More examples can be found here.
import mc
from mc.builtin import validators
generator = mc.PhraseGenerator(
samples=["hello world", "world of cuties", "bruh"]
)
phrase = generator.generate_phrase(
validators=[validators.words_count(minimal=4)]
)
print(phrase)
# >>> "hello world of cuties"