1 / 30

LING 388: Language and Computers

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.

mitch
Download Presentation

LING 388: Language and Computers

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. LING 388: Language and Computers Sandiway Fong 10/10 Lecture 14

  2. Administrivia Did you attempt Homework 3 as recommended?

  3. Administrivia • Today is a lab class • want to pick up where we left off two lab classes ago..

  4. 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

  5. Prepositional Phrase Attachment • “Quick Fix” grammar:

  6. Prepositional Phrase Attachment • Quick Fix” grammar parses: But grammar can’t get this parse

  7. 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

  8. 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].

  9. Prepositional Phrase Attachment • Parses with transformed grammar:

  10. Prepositional Phrase Attachment • Parses with transformed grammar: this parse is unavailable with the “quick fix” grammar

  11. Exercise 1 • What parses do we get for “a boy with a telescope with a limp with no money?”

  12. Exercise 1 • What parses do we get for “a boy with a telescope with a limp with no money?”

  13. Exercise 1 • What parses do we get for “a boy with a telescope with a limp with no money?”

  14. Exercise 1 • What parses do we get for “a boy with a telescope with a limp with no money?”

  15. Exercise 1 • What parses do we get for “a boy with a telescope with a limp with no money?”

  16. Exercise 1 • What parses do we get for “a boy with a telescope with a limp with no money”?

  17. 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].

  18. 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

  19. 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

  20. Exercise 2 • Assume untransformed grammar is:

  21. 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

  22. Exercise 2 • Check your parses for NPs: • a boy with a telescope with a limp

  23. Exercise 2 • Check your parses for NPs: • a boy with a telescope with a limp with no money

  24. Exercise 2 • Check your parses for NPs: • a boy with a telescope with a limp with no money

  25. Exercise 2 • Check your parses for NPs: • a boy with a telescope with a limp with no money

  26. Exercise 2 • Check your parses for NPs: • a boy with a telescope with a limp with no money

  27. Exercise 2 • Check your parses for NPs: • a boy with a telescope with a limp with no money

  28. Exercise 2 • Check your parses for NPs: • a boy with a telescope

  29. 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].

  30. 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?

More Related