Presentation is loading. Please wait.

Presentation is loading. Please wait.

LING/C SC/PSYC 438/538 Lecture 24 Sandiway Fong.

Similar presentations


Presentation on theme: "LING/C SC/PSYC 438/538 Lecture 24 Sandiway Fong."— Presentation transcript:

1 LING/C SC/PSYC 438/538 Lecture 24 Sandiway Fong

2 Today's Topics Homework 11 Review
(Reminder: Homework 12 due tomorrow night) Agreement example Dealing with left recursion by grammar transformation

3 Homework 11 Review Question 1: write a Prolog CFG for the following sentences: John ate (sensibly) (intransitive eat) I fish (intransitive fish) I ate fish (transitive eat) Bill ate rice Harry ate roast beef Note: you can use lowercase names… (or quotes, e.g. 'John') Note: use Penn Treebank tagset for words (see inside the cover of your textbook) nnp(prp(i)) --> [i]. nnp(nnp(john)) --> [john]. vbd(vbd(ate)) --> [ate].

4 Homework 11 Review Question 2: expand your grammar to handle these sentences: I ate fish, and Bill ate rice *I ate fish, Bill ate rice I ate fish, Bill ate rice, and Harry ate roast beef Note: the comma can be a quoted terminal, e.g. [','] comma(comma(',')) --> [',']. ','(','(',')) --> [',']. Note: be careful of left recursion on S List: (i) S; (ii) S, and S; (iii) S, S, and S (Stanford Parser)

5 Subject Verb Agreement
We need feature percolation: Form Ending Comment eat uninflected not 3rd person singular eats -s 3rd person singular ate -ed past eaten -en past participle eating -ing gerund Subject and VP come together at this rule Person Number Ending POS tags eats *eat Person Number Ending

6 Subject Verb Agreement
Implementation: using POS tags Constraint table: % table of Person Number Tag possible combinations table(3,pl,vb). table(3,pl,vbd). table(3,sg,vbz). table(3,sg,vbd). Person, Number from Subject NP POS tag from verb

7 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

8 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

9 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

10 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): vp vp pp vp pp pp vp pp pp pp vp pp pp pp pp infinite loop… Note: other extra arguments not shown here …

11 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). Note: w is a fresh non-terminal that takes 2 arguments 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 x is the recursive nonterminal [z] [y] x x Let's write some code!


Download ppt "LING/C SC/PSYC 438/538 Lecture 24 Sandiway Fong."

Similar presentations


Ads by Google