LING/C SC/PSYC 438/538 Lecture 26 Sandiway Fong
Administrivia No new homework today
538 Presentations Tuesday: November 27th Thursday: November 29th Scheduling Topic selection: already begun Talk length: 8 mins first come, first served basis Email me your 1st, 2nd and 3rd choices Email me your 1st, 2nd and 3rd choice of presentation dates: Tuesday: November 27th Thursday: November 29th Tuesday: December 4th
538 Presentations Check the table:
Left recursion and Prolog Left recursive grammars: we know from an earlier lecture that left recursive rules are a no-no given Prolog’s left-to-right depth- first computation rule… s a ... Example: s --> a, [!]. a --> ba, [a]. a --> a, [a]. ba --> b, [a]. b --> [b]. ?- s([b,a,!],[]). ERROR: Out of local stack rule for nonterminal a immediately calls a
Preposition Phrase (PP) Attachment The preferred syntactic analysis is a left recursive parse Examples: John saw the boy with a telescope (structural ambiguity: automatically handled by Prolog) withinstrument withpossessive
Preposition Phrase (PP) Attachment The preferred syntactic analysis is a left recursive parse Can “stack” the PPs: John saw the boy with a limp with Mary with a telescope ambiguity: withpossessive , withaccompaniment, withinstrument
Preposition Phrase Attachment Linguistically: PP (recursively) adjoins to NP or VP np(np(NP,PP)) --> np(NP), pp(PP). vp(vp(VP,PP)) --> vp(VP), pp(PP). Left recursion gives Prolog problems Derivation (top-down, left-to-right) sentential forms: vp vp pp vp pp pp vp pp pp pp vp pp pp pp pp infinite loop… Note: other extra arguments not shown here …
Transformation Apply the general transformation: to NP and VP rules: np(np(DT,NN)) --> dt(DT,Number), nn(NN,Number). np(np(NP,PP)) --> np(NP), pp(PP). vp(vp(VBD,NP)) --> vbd(VBD), np(NP). vp(vp(VP,PP)) --> vp(VP), 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]. Note: w is a fresh non-terminal that takes 2 arguments x(x(X,y)) --> x(X), [y]. x(x(z)) --> [z]. [z] [y] x x x is the recursive nonterminal [z] [y] x x Let's write a grammar!