![]() |
|
P is for Practical | |
PerlMonks |
comment on |
( #3333=superdoc: print w/replies, xml ) | Need Help?? |
Hello Monks, I'm trying something new that I've been bouncing around in my head since bliako posted his markovian meditation n-dimensional statistical analysis of DNA sequences (or text, or ...). bliako has all these interesting and abstruse scripts that are right on the edge of what I can replicate. I was able to do so once with the Markovian Frankentext of that thread but could not do it again. I want to reach for something much simpler, indeed as simple as I can imagine it as an SSCCE. With that as an introduction, I'll put a statement of the problem in readmore tags: In 1972, we could order things called "Mad Libs" which were text templates for writing stories. I would like to create one with stochastic inputs. The templates are read as files using Path::Tiny after which they undergo the substitutions using Text::Template. The lexicographic order provides a basic cause/effect continuum that makes sense. I have parts of this written, hopefully well enough so that I describe what I seek. I worked up an example on github. It is 2.8k now and I will say that it is less than 50 k and hope never to have to update this line. These programs can generate a lot of story pretty quickly, so I'll do my part to keep bandwidth to modem levels. I present output:
then source:
So, I'm getting good intermediary results. What I want to do is map the values from $data to populate %var instead. The first column is the keys of the hash. Those that follow are probable values. For starters, I would like to make them equaprobable, so a mapping function would get a pseudorandom on the unit interval, and multiply it by the cardinality of the possibilities. I haven't done that in perl, so I'm fishing for ways to do that. Also, I'm looking for a little logic that returns the compliment of left and right in 'orientation'. I've got ways to do these things, they just all look like leftover fortran and C. I'm looking for perl solutions. Maybe I need to represent these data entirely differently.... Thanks for your comment In reply to making a markovian "mad lib" by Aldebaran
|
|