Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Sentence format

by marius (Hermit)
on Feb 21, 2001 at 21:37 UTC ( #59980=note: print w/ replies, xml ) Need Help??


in reply to Sentence format

Assuming you keep your articles/verbs/nouns in different files, this wouldn't be terribly difficult:

my(@sentenceformats) = ( 'a v n', 'a v n v n' ); #pick a sentence format -- there's probably a much #easier way to do this! my($sent) = int(rand($#sentenceformats))); my(@format) = split(/ /, $sentenceformat[$sent]); for (@format) { if (/a/) { #pick a article } elsif (/v/) { #pick a verb } elsif (/n/) { #pick a noun } else { warn "Unknown sentence fragment\n"; }; };

Of course, this is all untested, and I /think/ it should work.. YMMV.

-marius


Comment on Re: Sentence format
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://59980]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (8)
As of 2014-12-25 18:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (162 votes), past polls