Lecture: 11-14-2012

posted Nov 14, 2012, 6:12 AM by Samuel Konstantinovich   [ updated Nov 20, 2012, 5:46 AM ]


IF YOU HAVE A TRIP FRIDAY: You must take the quiz at 7:45AM in the math office (room 402)

Do now: Here are some sentences that would make you cry: (I don’t expect your sentence generator to be able to generate these)

Try to decypher the meaning of these sentences that have punctuation missing:

1. Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo.

2. Ted while Bill had had had had had had had had had had had a better effect on the teacher.

In the same spirit of the aforementioned sentences, here is a poem:

Pinyin form:

Shíshì shīshì Shī Shì, shì shī, shì shí shí shī.
Shì shíshí shì shì shì shī.
Shí shí, shì shí shī shì shì.
Shì shí, shì Shī Shì shì shì.
Shì shì shì shí shī, shì shǐ shì, shǐ shì shí shī shìshì.
Shì shí shì shí shī shī, shì shíshì.
Shíshì shī, Shì shǐ shì shì shíshì.
Shíshì shì, Shì shǐ shì shí shì shí shī.
Shí shí, shǐ shí shì shí shī shī, shí shí shí shī shī.
Shì shì shì shì.
Traditional form:

____________________BACK TO WORK NOW_____________________

;GOAL: Sentence Generation (Day 2)


;A better sentece is in the format:

; Noun Phrase + Verb Phrase


; The chair + runs.

; The big kid + quickly ran.

; The dog + solemnly spins.

; The sad emo puppy + happily enthusiastically lollygags.

;So lets make a better sentence!

;You should have written the following already:

(define (getNth L n)

    (if (= n 0)

        (car L)

        (getNth (cdr L) (- n 1))))

(define (getOne L)

    (getNth L (random (length L))))

;basic word lists:

    (define nouns '(cat chair buffalo crumpet))

    (define verbs '(runs sings codes writes skateboards))

;get-word commands (that put the word into a list for ease of appending)

    (define (getNoun) (list (getOne nouns)))

    (define (getVerb) (list (getOne verbs)))

;########### Other word lists###########:

;1. You need to write a list of adverbs and adjectives, as well as the getAdverb and getAdjective. Optionally you can write properNouns and proNouns as well! 

;make a short list of 3 of each for now

;2. This NEXT idea is going to help you write the much better sentence generator:


;This is how you can have a cond statement randomly chooses

;(you have to replace the ... with what you want it to do.)

;between 2 options:


;  ((= 0 (random 2)) ... ))

;  (else ... )


;Or 4 options:


;  ((= 0 (random 4)) ... ))

;  ((= 0 (random 3)) ... ))

;  ((= 0 (random 2)) ... ))

;  (else ... )


;3. Now using this idea we want to make a nounPhrase generator, and a verb phrase generator. The results of which can be appended to create a sentence. 

;sample output:

;(nounPhrase) -> ( the lazy dog )

;(nounPhrase) -> ( the quick brown fox )

;sample output:

;(verbPhrase) -> ( jumps )

;(verbPhrase) -> ( uselessly dances )

;For the noun phrase:

;Sometimes you want to have a noun by itself. (with ‘the’ in front of it)

;Sometimes you want ‘the’ + adjective + noun.

;So maybe your options would be:

;(append ‘(the) (getNoun))

;(append ‘(the) (getAdjective) (getNoun))

;After you write your nounPhrase generator, try verbPhrase:

;For the verb phrase two basic ideas would be:

; verb

; adverb + verb

;4. After you get a nounPhrase and verbPhrase generator, add more options to make more complex sentences. Your goal should be to write the most awesome sentence generator you can. 

Here are some ideas:



;transitive vs. intransitive verbs. 

;make your getAdjective function return 1 or more adjectives.

;make your getAdverb function return 1 or more adverbs.

;pluralization (requires you to have separate noun and verb lists for plural.)