300 likes | 398 Views
LING 388: Language and Computers. Sandiway Fong 10/10 Lecture 14. Administrivia. Did you attempt Homework 3 as recommended?. Administrivia. Today is a lab class w ant to pick up where we left off two lab classes ago. Prepositional Phrase Attachment.
E N D
LING 388: Language and Computers Sandiway Fong 10/10 Lecture 14
Administrivia Did you attempt Homework 3 as recommended?
Administrivia • Today is a lab class • want to pick up where we left off two lab classes ago..
Prepositional Phrase Attachment • Two lab classes ago, we discussed how to handle left recursion for prepositional phrase (PP) attachment for examples like: • John saw the boy with a telescope • Left recursive rules: • NP NP PP • VP VP PP
Prepositional Phrase Attachment • “Quick Fix” grammar:
Prepositional Phrase Attachment • Quick Fix” grammar parses: But grammar can’t get this parse
Prepositional Phrase Attachment • We applied the transformation: • to NP rules: • np(np(DT,NN)) --> dt(DT), nn(NN). • np(np(NP,PP)) --> np(NP), pp(PP). x(x(z,V)) --> [z], v(V). v(v(y,V)) --> [y], v(V). v(v(y)) --> [y]. x(x(z)) --> [z]. x(x(X,y)) --> x(X), [y]. x(x(z)) --> [z]. [z] [y] x x
Prepositional Phrase Attachment • Transformed grammar: [z] [z] [y] [y] x(x(z,V)) --> [z], v(V). v(v(y,V)) --> [y], v(V). v(v(y)) --> [y]. x(x(z)) --> [z]. x(x(X,y)) --> x(X), [y]. x(x(z)) --> [z].
Prepositional Phrase Attachment • Parses with transformed grammar:
Prepositional Phrase Attachment • Parses with transformed grammar: this parse is unavailable with the “quick fix” grammar
Exercise 1 • What parses do we get for “a boy with a telescope with a limp with no money?”
Exercise 1 • What parses do we get for “a boy with a telescope with a limp with no money?”
Exercise 1 • What parses do we get for “a boy with a telescope with a limp with no money?”
Exercise 1 • What parses do we get for “a boy with a telescope with a limp with no money?”
Exercise 1 • What parses do we get for “a boy with a telescope with a limp with no money?”
Exercise 1 • What parses do we get for “a boy with a telescope with a limp with no money”?
Exercise 2 • We’ve learnt the first transform: • turn left recursion into right recursion • (that Prolog can deal with) x(x(z,V)) --> [z], v(V). v(v(y,V)) --> [y], v(V). v(v(y)) --> [y]. x(x(z)) --> [z]. x(x(X,y)) --> x(X), [y]. x(x(z)) --> [z]. • There’s a second type of transform: • turn left recursion into right recursion • but produces a left recursive parse x(X) --> [z], w(X,x(z)). x(x(z)) --> [z]. w(W,X) --> [y], w(W,x(X,y)). w(x(X,y),X) --> [y]. x(x(X,y)) --> x(X), [y]. x(x(z)) --> [z].
Exercise 2 • There’s a second type of transform: • turn left recursion into right recursion • but produces a left recursive parse x(X) --> [z], w(X,x(z)). x(x(z)) --> [z]. w(W,X) --> [y], w(W,x(X,y)). w(x(X,y),X) --> [y]. x(x(X,y)) --> x(X), [y]. x(x(z)) --> [z]. Note: nonterminal w requires two arguments
Exercise 2 • Apply the transformation: • to NP rules: • np(np(DT,NN)) --> dt(DT), nn(NN). • np(np(NP,PP)) --> np(NP), pp(PP). x(X) --> [z], w(X,x(z)). x(x(z)) --> [z]. w(W,X) --> [y], w(W,x(X,y)). w(x(X,y),X) --> [y]. x(x(X,y)) --> x(X), [y]. x(x(z)) --> [z]. [z] [y] x x
Exercise 2 • Assume untransformed grammar is:
Exercise 2 • Check your parses for NPs: • a boy with a telescope • a boy with a telescope with a limp • a boy with a telescope with a limp with no money
Exercise 2 • Check your parses for NPs: • a boy with a telescope with a limp
Exercise 2 • Check your parses for NPs: • a boy with a telescope with a limp with no money
Exercise 2 • Check your parses for NPs: • a boy with a telescope with a limp with no money
Exercise 2 • Check your parses for NPs: • a boy with a telescope with a limp with no money
Exercise 2 • Check your parses for NPs: • a boy with a telescope with a limp with no money
Exercise 2 • Check your parses for NPs: • a boy with a telescope with a limp with no money
Exercise 2 • Check your parses for NPs: • a boy with a telescope
Exercise 3 • Class exercise • do the same transformation for • vp(vp(VP,PP)) --> vp(VP), pp(PP). • assuming • vp(vp(VBD,NP)) --> vbd(VBD), np(PP). • vbd(vbd(saw)) --> [saw]. • Add in standard rules for sentence: • s(s(NP,VP)) --> np(NP), vp(VP). • np(np(i)) --> [i].
Exercise 3 • Test on: • I saw a boy with a telescope • I saw a boy with a telescope with a limp • I saw a boy with a telescope with a limp with no money • How many parses do you get for each case?