Earlier quoted context omitted.
In his dataset, all sentences start at the beginning of the line and end at it's end. This is strictly a toy, no one serious would use this for anything anyways.
> In his dataset, all sentences start at the beginning of the line and end at it's end. Right, but the sentence start is taken from the first word of a random state transition pair, not the first word of a random sentence.
Fast Markov chains in ~20 lines of sh, grep, cut and Awk
11–20 of 42 posts
Re: Fast Markov chains in ~20 lines of sh, grep, cut and Awk
#12This is super cool. I love things like this being done in gnuland.
Re: Fast Markov chains in ~20 lines of sh, grep, cut and Awk
#13> At first, mrkwords.sh will pick a random line from the model and pick the first word of the pair as the first word of our output message. In my opinion, this is not the best way to do it. This will generate sentences that start with words that can never start sentences. The best thing to do is to define a "sentinel" to go at the start and end of a sentence. For example, a "$" sign, or a NUL byte. Then to generate a…
Re: Fast Markov chains in ~20 lines of sh, grep, cut and Awk
#14Earlier quoted context omitted.
> The best thing to do is to define a "sentinel" to go at the start and end of a sentence. For example, a "$" sign, or a NUL byte. The $ sign would get in the way if people actually use it in conersation, and maybe other things don't like the NUL byte. Maybe '\x1F' (ASCII Unit Separator) or '\x1E' (ASCII Record Separator) are better candidates?
Or just upper case first letter and full stop?
Re: Fast Markov chains in ~20 lines of sh, grep, cut and Awk
#15Re: Fast Markov chains in ~20 lines of sh, grep, cut and Awk
#16https://ptgmedia.pearsoncmg.com/images/9780201615869/samplep...
One thing I've noticed from playing with these types of programs is the number of words to use as a hash. Two to start with of course, will quickly reproduce the sample text once you get to only five or six prefix words. Where as two prefix words usually generate nonsense, the sweet spot to a believable quality is only three or four words as a prefix with five or more reproducing the original text. The larger the varied sample text, the much better the results. Furthermore, only breaking words on whitespace creates even better quality output than assuming you need to tinker with the punctuation.
Re: Fast Markov chains in ~20 lines of sh, grep, cut and Awk
#17The best read for something like this is The Practice of Programming which is a great little book to have in general. This link to a sample chapter covers the entire analysis and creation of a markov chain program, none of which require many lines of code. https://ptgmedia.pearsoncmg.com/images/9780201615869/samplep... One thing I've noticed from playing with these types of programs is the number of words to use as a…
See also https://en.wikipedia.org/wiki/Google_Ngram_Viewer which recently popularized the term n-gram.
Re: Fast Markov chains in ~20 lines of sh, grep, cut and Awk
#18Re: Fast Markov chains in ~20 lines of sh, grep, cut and Awk
#19I'm bookmarking this as a bash script reference.
Re: Fast Markov chains in ~20 lines of sh, grep, cut and Awk
#20This is awesome because it is a real shell script that does something interesting AND it's well documented. I'm bookmarking this as a bash script reference.