This preview shows pages 1–3. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: CS51 Project 1b: Aye, Sea Turtles Due: Tuesday, 24 February 2009 at 11:59 PM Total Points: 50 (including 5 style points) 1 Introduction to Pirate CFG Ahoy me harties! You are going to teach your computer to speak pirate! Well, not really, but you are going to write a random sentence generator using a formalism called a Context Free Grammar (CFG). To do this, you will need to learn how to use Schemes random function and learn how to work with a CFG. For this part of the project, please use the Intermediate Student with Lambda language. 1.1 What is a Context Free Grammar? A grammar is a formalism for representing constraints about a language. Grammars can, in fact, be considered a theory of language, since a grammar, by its very nature, contains a description of the constraints that determine whether a particular word sequence is a valid sentence or whether it is disordered garbage. For our purposes, a grammar will consist of a collection of rules (to be represented in Scheme as a dictionary). For this assignment, we will use a specific type of grammar, known as a context free grammar , where each rule consists of a single item mapping to one or more sets of items. For this assignment we will have two different types of CFG rules: 1. non-terminal rules which map to a list of sequences of terminal or non-terminal rules 2. terminal rules map to a list of possible words Here is an example of a CFG for a small subset of English 1 : 1 If you are curious about the letters used in these rules, they are fairly standard abbreviations from Linguistics: S = sentence, NP = Noun Phrase, VP = Verb Phrase, Det = Determiner, N = Nouns, V = Verb, Name = Proper Name 1 1 INTRODUCTION TO PIRATE CFG CS51 Project 1b: Aye, Sea Turtles Non-terminal rules: S NP VP NP Det N | Name VP V NP Terminal rules: Det a | the N dog | cat Name Greg | Ramin V chases | bites In the above representation, means can expand to one of the following and | means or. Words in quotes (on the right-hand side of terminal rules) are the actual words that will appear in a sentence generated by the grammar. These are frequently referred to as the terminal symbols of the language. Words on the left hand side of rules represent syntactic categories in the language being defined. These are called the non-terminal symbols of the language since these symbols will not appear in a sentence generated by the grammar....
View Full Document
This note was uploaded on 07/26/2009 for the course COMPUTERSC CS51 taught by Professor Gregmorrisett during the Spring '09 term at Harvard.
- Spring '09