lecture13

advertisement
LING 388: Language and Computers
Sandiway Fong
Lecture 13
Administrivia
• Another Homework on recursion
– Homework 5
– due next Wednesday by midnight…
Left to Right Recursive Transformation
x --> [z], v.
v --> [y], v.
v --> [y].
x --> [z].
1.
2.
x(x(z,V)) --> [z], v(V).
v(v(y,V)) --> [y], v(V).
v(v(y)) --> [y].
x(x(z)) --> [z].
np --> np, pp.
np --> det, nn.
np --> det, nn, v.
v --> pp, v.
v --> pp.
np --> det, nn.
np(np(D,N,V)) --> det(D), nn(N), v(V).
v(v(PP,V)) --> pp(PP), v(V).
v(v(PP)) --> pp(PP).
np(np(D,NN)) --> det(D), nn(NN).
Last Time
We developed the following rules:
1.
sentence(s(X,Y)) --> np(X), vp(Y).
2.
pp(pp(X,Y)) --> in(X), np(Y).
3.
np(np(X)) --> prp(X).
4.
np(np(nnp(mary))) --> [mary].
5.
np(np(nnp(john))) --> [john].
6.
np(np(nnp(bill))) --> [bill].
7.
np(np(D,NN)) --> det(D), nn(NN).
8.
np(np(D,NN,V)) --> det(D), nn(NN), v(V).
9.
v(v(PP,V)) --> pp(PP), v(V).
10. v(v(PP)) --> pp(PP).
11. v2(v2(PP,V2)) --> pp(PP), v2(V2).
12. v2(v2(PP)) --> pp(PP).
13. vp(vp(V,NP,V2)) --> verb(V), np(NP), v2(V2).
14. vp(vp(V,X)) --> verb(V), np(X).
15. vp(vp(V,X)) --> verb(V), sbar(X).
16. sbar(sbar(X,S)) --> c(X), sentence(S).
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
c(in(that)) --> [that].
in(in(with)) --> [with].
a(jj(big)) --> [big].
a(jj(shiny)) --> [shiny].
a(jj(red)) --> [red].
prp(prp(i)) --> [i].
prp(prp(me)) --> [me].
nn(nn(boy)) --> [boy].
nn(nn(limp)) --> [limp].
nn(nn(telescope)) --> [telescope].
nn(nn(bus)) --> [bus].
nn(nn(A,NN)) --> a(A), nn(NN).
verb(vbd(noticed)) --> [noticed].
verb(vbd(saw)) --> [saw].
det(dt(the)) --> [the].
det(dt(a)) --> [a].
Left recursive np  np, pp and vp  vp, pp
adjunction rules transformed into right recursive
rules involving v and v2, respectively
grammar-transformed.pl
Last Time
1.
2.
3.
4.
5.
6.
7.
8.
sentence(s(X,Y)) --> np(X), vp(Y).
pp(pp(X,Y)) --> in(X), np(Y).
np(np(X)) --> prp(X).
np(np(nnp(mary))) --> [mary].
np(np(nnp(john))) --> [john].
np(np(nnp(bill))) --> [bill].
np(np(D,NN)) --> det(D), nn(NN).
np(np(np(X,Y),Z)) --> det(X), nn(Y),
pp(Z).
9. vp(vp(V,X)) --> verb(V), np(X).
10. vp(vp(V,NP,PP)) --> verb(V), np(NP),
pp(PP).
11. vp(vp(V,X)) --> verb(V), sbar(X).
12. sbar(sbar(X,S)) --> c(X), sentence(S).
Quick Fix grammar
grammar-quickfix.pl
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
c(in(that)) --> [that].
in(in(with)) --> [with].
a(jj(big)) --> [big].
a(jj(shiny)) --> [shiny].
a(jj(red)) --> [red].
prp(prp(i)) --> [i].
prp(prp(me)) --> [me].
nn(nn(boy)) --> [boy].
nn(nn(limp)) --> [limp].
nn(nn(telescope)) --> [telescope].
nn(nn(bus)) --> [bus].
nn(nn(A,NN)) --> a(A), nn(NN).
verb(vbd(noticed)) --> [noticed].
verb(vbd(saw)) --> [saw].
det(dt(the)) --> [the].
det(dt(a)) --> [a].
Step 4
• Step 4:
– Compare the transformed grammar parses with
those obtained using the “Quick Fix” grammar on
the NP
• a boy with a telescope with a limp
• number of parses?
• attachment of the PPs?
Last Time
Modification Relations
Quick Fix
PP adjunction to NP/PP
telescope  boy, limp  boy
✅
telescope  see, limp  see
✅
telescope  boy, limp  see
✅
✅
telescope  see, limp  telescope
✅
✅
telescope  boy, limp  telescope
✅
✅
Example: I saw the boy with a telescope with a limp
Left to Right Recursive Transformation
Structures are right branching
They have extra v and v2 nodes
Step 5
• Step 5:
– in step 4, we obtained a
right recursive parse
– Modify your natural
language grammar to
produce a left recursive
parse following the
template on the right…
– Test your grammar
• Example:
–
–
–
–
x(x(z,V)) --> [z], v(V).
v(v(y,V)) --> [y], v(V).
v(v(v)) --> [y].
x(x(z)) --> [z].
• Modified grammar:
Homework 5
• Regular sentence:
– the rat ate the cheese
• Object relative clause construction:
–
–
–
–
object of the sentence is missing
"moves" to become a new head noun
the cheese (that) the rat ate
[NP [NP the cheese] [SBAR [S [NP the rat][VP[VBD
ate] ____ ]]]]
Homework 5
• Subject relative clause construction:
– subject "moves" to become a new head noun
– the rat that ate the cheese
– [NP [NP the rat] [SBAR that [S ____ [VP[VBD ate] [NP the
cheese]]]]]
Homework 5
• Implement another kind of recursion:
– Object relative clauses
• the cat that saw the rat that saw the cheese that …
• [NP the cat [SBAR that [S saw [NP the rat [SBAR that [S saw [NP
the cheese that … ]]]]]]]
• the cheese that the rat ate
• the cheese that the rat that the cat saw ate
• the cheese that the rat that the cat that the dog chased
saw ate
Homework 5
• Other kinds of recursion, e.g.
– Object relative clauses
• the cheese that the rat ate
Homework 5
• Other kinds of recursion, e.g.
– Object relative clauses
• the cheese that the rat that the cat saw ate
Homework 5
• the cheese that the rat that the cat saw ate was rotten .
Homework 5
• the cheese that the rat that the cat that the dog chased saw ate was rotten .
Homework 5
• Use grammar.pl as the starting point
• Submit your revised grammar.
• Submit your runs
Download