This is a Go package that uses Markov chains to generate random text.
- Import the package:
import "github.com/RedSkotina/xrich"
- Create the
MarkovChain
Struct
c := xrich.NewMarkovChain()
- Fill variable of type
[]string
with text blocks represent logical pieces of text
textBlocks := []string{"string1","string2"}
- Pass variable to function
Build
for initializing internal state table of theMarkovChain
c.Build(textBlocks)
- Call
GenerateSentense
method with maximum word numberMAXGEN
s := c.GenerateSentence(MAXGEN)
or
- Call
GenerateAnswer
method with trigger messagemessage
and 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 ...