56
\$\begingroup\$

Problem:

Generate a sentence that can be read and understood. It must contain a subject, verb, and object, and tenses and plurals must match. The program must also be able to generate several different sentences to qualify.

Rules:

  • Hard-coding the sentences is not permitted, and nor is reading them directly from a file (i'm looking at you, unclemeat)
  • You can have any number of word lists
  • Submit an example sentence or 2 that have been generated by your program
  • Any language is accepted
  • It's a , so the most upvoted answer wins
\$\endgroup\$
  • 7
    \$\begingroup\$ I think it's clear from some of the answers (MatLab I'm looking at you) that you should modify the rules such that data-mining is not allowed to pull consecutive words from any source. \$\endgroup\$ – Carl Witthoft Feb 21 '14 at 13:50
  • \$\begingroup\$ While I'm being a smartass: since it's purely a popularity contest, someone should just post a HotModelBikini jpg. That'll get more votes than anything. \$\endgroup\$ – Carl Witthoft Feb 21 '14 at 15:03
  • 7
    \$\begingroup\$ I'll upvote anyone who uses repetitions of "buffalo" or "fish" as sample sentences! \$\endgroup\$ – user15259 Feb 21 '14 at 16:19
  • 7
    \$\begingroup\$ Most answers here either mine valid, full sentences from text sources, or generate output that does not meet the criteria. To me, both approaches seem against the spirit of the question! If someone really wants to impress, might I suggest a program that starts with a set of valid sentence structures like [Adjective] [pl. noun] [verb] [adjective] [pl. noun] and pulls from a real dictionary (maybe using one of the Dictionary APIs available out there) to fill in the blanks? I'd write it myself if I had a few minutes to spare! :( After all... Lazy Developers Write Lousy Programs. \$\endgroup\$ – Brian Lacy Feb 21 '14 at 17:21
  • 1
    \$\begingroup\$ @Pureferret Word lists would be lists of individual words. Hard coding would be a list of complete sentences. With word lists, you would typically need some logic in the program to piece together a complete sentence. With hard coded sentences, you basically just need a print statement. \$\endgroup\$ – 8bittree Feb 27 '14 at 15:03

29 Answers 29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.