This is a Go package that uses Markov chains to generate random text.
- Import the package:
import "github.com/RedSkotina/xrich"
- Create the
MarkovChainStruct
c := xrich.NewMarkovChain()
- Fill variable of type
[]stringwith text blocks represent logical pieces of text
textBlocks := []string{"string1","string2"}
- Pass variable to function
Buildfor initializing internal state table of theMarkovChain
c.Build(textBlocks)
- Call
GenerateSentensemethod with maximum word numberMAXGEN
s := c.GenerateSentence(MAXGEN)
or
- Call
GenerateAnswermethod with trigger messagemessageand maximum word numberMAXGEN
s := c.GenerateAnswer(message, MAXGEN)
This is a Telegram bot, which reacts on all messages in chat and sends generated text.
xrich_telebot -token=TELEGRAM_BOT_TOKEN -max=MAXWORDS file1.jsonl file2.jsonl ...