Small markov generate example using the RiTa library for generating sentences script src https unpkg com rita script script console log version RiTa VERSION var inputText The blue bus drove by a crowded street All the children were singing It was a great bus ride var markov new RiTa markov 2 RiTa markov nFactor options what is nFactor ans n factor the length of each n gram stored in the model markov addText inputText var sentences markov generate 2 console log sentences send result to output e g output The blue bus ride It was a great bus drove by a crowded street script Other Rita package tests style body min height 400px style script src https unpkg com p5 script script src https unpkg com rita script script function setup createCanvas 200 300 background 250 textSize 20 noStroke let words RiTa tokenize The elephant was riding a bike Oh No for let i 0 i words length i text words i 50 50 i 20 var inputText The blue bus drove by a crowded street All the children were singing It was a great bus ride var markov new RiTa markov 2 markov addText inputText var sentences markov generate 2 console log sentences script Same example but using 2 8 31 of Rita from CDNJS again markov example For this markov example set the extra options turn on the extra trace script src https cdnjs cloudflare com ajax libs rita 2 8 31 rita js script script console log RiTa Version RiTa VERSION var inputText The temperature parameter acts as a knob to adjust the probability that input elements will be selected for the output At higher values infrequent words are more likely to be chosen while at lower values the most frequent inputs are more likely to be output If no value is provided then tokens are chosen according to their relative frequency in the input var markov new RiTa markov 2 trace false limit nFactor to 2 markov addText inputText var sentences markov generate 6 allowDuplicates false console log result sentences send result to output e g output lots of sentences based on the example script
ed street All the children were singing It was a great bus ride var markov new RiTa markov 2 markov addText inputText var sentences markov generate 2 console log sentences script Same example but using 2 8 31 of Rita from CDNJS again markov example For this markov example set the extra options turn on the extra trace script src https cdnjs cloudflare com ajax libs rita 2 8 31 rita js script script console log RiTa Version RiTa VERSION var inputText The temperature parameter acts as a knob to adjust the probability that input elements will be selected for the output At higher values infrequent words are more likely to be chosen while at lower values the most frequent inputs are more likely to be output If no value is provided then tokens are chosen according to their relative frequency in the input var markov new RiTa markov 2 trace false limit nFactor to 2 markov addText inputText var sentences markov generate 6 allowDuplicates false console log result sentences send result to output e g output lots of sentences based on the example script