in reply to Sentence format
You've got a bunch of lists; the basic idea seems pretty simple, if you lay your data out right. Select random form, then, for each wordtype in the form, select a random word of that type.
Here's one way :store your words in a hash of array references, e.g.
$word{noun} = [ qw(bird dog table dollar econonmy ennui) ]; $word{verb] = [ qw(eat drink fire annoy) ]; $word{article}= [ qw(a the an) ];
(this *can* be done more elegantly =)
Then, you can specify your formats however you'd like, say, as an array of strings. Use rand on both the array of sentence forms, and on the anonymous arrays of each word type.
To get the last index in an array: $#arrayname, and remember, Perl array indices start at 0!
HTH then
Philosophy can be made out of anything. Or less -- Jerry A. Fodor
|
|---|