[Haskell-cafe] Markov Text Generator & Randomness

Charles-Pierre Astolfi cpa at crans.org
Thu Jul 24 02:29:35 UTC 2014


Hi -cafe,

I'm coding a Markov Text Generator (of order 1). Basically, you have a
source text, and knowing the frequencies of pairs of consecutive
words, you generate a somewhat syntactically correct text from this.

Here's the link to my code and to a source text you can use as example.

test.txt
http://lpaste.net/raw/4004174907431714816
code
http://lpaste.net/4147715261379641344

The kickers is that this code generates sentences with consecutive
words that never appears next to each other in the source text.
For example, the code generated "They sat over at because old those
the lighted.", but "over at" never occurs in the source text, so it
shouldn't occur in a generated sentence.

The makeDb function gives is correct, so my problem actually lies in
generate and/or in draw.

I think there's something about RVar that I messed up, but I don't see
the problem. Any ideas?

Cheers,
-- 
Charles-Pierre


More information about the Haskell-Cafe mailing list