04-Assignment-1-RSG - CS107 Spring 2007 Handout 04 April 4,...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
CS107 Handout 04 Spring 2007 April 4, 2007 Assignment 1: Random Sentence Generator Based on an old CS107 assignment written by Julie Zelenski. First three pages taking verbatim from someone else’s handout. The Inspiration In the past decade or so, computers have revolutionized student life. In addition to providing no end of entertainment and distractions, computers also have also facilitated all sorts of student work from English papers to calculus. One important area of student labor that has been painfully neglected is the task of filling up space in papers, Ph.D. dissertations, extension requests, etc. with important sounding and somewhat grammatically correct random sequences. An area that’s been neglected, that is, until now. Due: Wednesday, April 11 th at 11:59 p.m. The Random Sentence Generator is a handy and marvelous piece of technology to create random sentences from a structure known as a context-free grammar . A grammar is a template that describes the various combinations of words that can be used to form valid sentences. There are profoundly useful grammars available to generate extension requests, generic Star Trek plots, your average James Bond movie, "Dear John" letters, and more. You can even create your own grammar! Fun for the whole family! Let’s show you the value of this practical and wonderful tool: Tactic #1: Wear down the TA's patience. I need an extension because I had to go to an alligator wrestling meet, and then, just when my mojo was getting back on its feet, I just didn't feel like working, and, well I'm a little embarrassed about this, but I had to practice for the Winter Olympics, and on top of that my roommate ate my disk, and right about then well, it's all a haze, and then my dorm burned down, and just then I had tons of midterms and tons of papers, and right about then I lost a lot of money on the four-square semi-finals, oh, and then I had recurring dreams about my notes, and just then I forgot how to write, and right about then my dog ate my dreams, and just then I had to practice for an intramural monster truck meet, oh, and then the bookstore was out of erasers, and on top of that my roommate ate my sense of purpose, and then get this, the programming language was inadequately abstract. Tactic #2: Plead innocence. I need an extension because I forgot it would require work and then I didn’t know I was in this class. Tactic #3: Honesty. I need an extension because I just didn't feel like working.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 What is a grammar? A grammar is a set of rules for some language, be it English, C++, Scheme, or something you just invent for fun. If you continue to study computer science, you will learn much more about languages and grammars in a formal sense. For now, we will introduce to you a particular kind of grammar called a context-free grammar ( CFG ). Here is an example of a simple CFG:
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/14/2010 for the course CS 107 taught by Professor Cain,g during the Spring '08 term at Stanford.

Page1 / 8

04-Assignment-1-RSG - CS107 Spring 2007 Handout 04 April 4,...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online