Download presentation
Presentation is loading. Please wait.
Published byDarlene Walters Modified over 9 years ago
1
LING/C SC/PSYC 438/538 Lecture 19 Sandiway Fong 1
2
Today's Topic Let's write a phrase structure grammar (PSG) using Prolog Mechanisms: 1.Extra argument for Prolog term representation of a parse 2.Extra arguments for feature value agreement 3.Dealing with left recursive rules: grammar transformation
3
Topics Mechanisms: 1.Extra argument for Prolog term representation of a parse 2.Extra arguments for feature value agreement 3.Dealing with left recursive rules: grammar transformation
4
Parse Let's write a simple grammar returning appropriate parse trees for sentences like: – John kicked the ball – the men kicked the ball – a man kicked the ball Stanford Parser: –(ROOT – (S – (NP (DT the) (NNS men)) – (VP (VBD kicked) – (NP (DT the) (NN ball)))))
5
Topics Mechanisms: 1.Extra argument for Prolog term representation of a parse 2.Extra arguments for feature value agreement 3.Dealing with left recursive rules: grammar transformation
6
Extra Arguments: Agreement Idea: – We can also use an extra argument to impose constraints between constituents within a DCG rule Example: – English determiner-noun number agreement – Data: the man the men a man *a men – Lexical Features: man singular men plural 6
7
Extra Arguments: Agreement Data: – the man/men – a man/*a men Grammar: (NP section) np(np(Y)) --> pronoun(Y). np(np(D,N)) --> det(D,Number), common_noun(N,Number). det(det(the),sg) --> [the]. det(det(the),pl) --> [the]. det(det(a),sg) --> [a]. common_noun(n(ball),sg) --> [ball]. common_noun(n(man),sg) --> [man]. common_noun(n(men),pl) --> [men]. pronoun(i) --> [i]. pronoun(we) --> [we]. –Idea: give determiners a number feature as well and make it agree with the noun Rules the can combine with singular or plural nouns a can combine only with singular nouns 7
8
Extra Arguments: Agreement Simplifying the grammar: det(det(the),sg) --> [the]. det(det(the),pl) --> [the]. det(det(a),sg) --> [a]. Grammar is ambiguous: – two rules for determiner the Agreement Rule (revisited): the can combine with singular or plural nouns i.e. the doesn’t care about the number of the noun DCG Rule: np(np(D,N)) --> det(D,Number), common_noun(N,Number). det(det(the),_) --> [the]. Note: _ is a variable used underscore character because we don’t care about the value of the variable 8
9
Extra Arguments: Agreement Note: Use of the extra argument for agreement here is basically “syntactic sugar” and lends no more expressive power to the grammar rule system i.e. we can enforce the agreement without the use of the extra argument at the cost of more rules Note: Use of the extra argument for agreement here is basically “syntactic sugar” and lends no more expressive power to the grammar rule system i.e. we can enforce the agreement without the use of the extra argument at the cost of more rules Instead of np(np(D,N)) --> det(D,Number), common_noun(N,Number). we could have written: np(np(D,N)) --> detsg(D), common_nounsg(N). np(np(D,N)) --> detpl(D), common_nounpl(N). detsg(det(a)) --> [a]. detsg(det(the)) --> [the]. detpl(det(the)) --> [the]. common_nounsg(n(ball)) --> [ball]. common_nounsg(n(man)) -->[man]. common_nounpl(n(men)) --> [men]. 9
10
Extra Arguments: Agreement English exhibits subject- verb agreement Examples: – John kicked the ball – The men kicked the ball – John kicks the balls – The men *kicks/kick the ball Constraint: 1.-s form of the verb is compatible with 3rd person singular only for the subject NP 2.uninflected form is not compatible with 3 rd person singular for the subject NP
11
Subject Verb Agreement We need feature percolation: eats *eat FormEndingComment eat uninflectednot 3 rd person singular eats-s3 rd person singular ate-edpast eaten-enpast participle eating-inggerund Person Number Person Number Ending Subject and VP come together at this rule Person Number Person Number Ending POS tags
12
Subject Verb Agreement Implementation: using POS tags Constraint table: –% table of Person Number Tag possible combinations –check(3,plural,vb). –check(3,plural,vbd). –check(3,singular,vbz). –check(3,singular,vbd). Person, Number from Subject NP POS tag from verb
13
Topics Mechanisms: 1.Extra argument for Prolog term representation of a parse 2.Extra arguments for feature value agreement 3.Dealing with left recursive rules: grammar transformation
14
Today’s Topic Left recursive parses: We know from an earlier lecture that left recursive rules are a no-no given Prolog’s left-to- right depth-first computation rule… Example: 1.s --> a, [!]. 2.a --> ba, [a]. 3.a --> a, [a]. 4.ba --> b, [a]. 5.b --> [b]. ?- s([b,a,!],[]). ERROR: Out of local stack s a a a a...
15
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) possessive with instrument with
16
Preposition Phrase (PP) Attachment The preferred syntactic analysis is a left recursive parse Can “stack” PPs: – John saw the boy with a limp with Mary with a telescope – ambiguity: with possessive, with accompaniment, with instrument
17
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): 1.vp 2.vp pp 3.vp pp pp 4.vp pp pp pp 5.vp pp pp pp ppinfinite loop…
18
Transformation Apply the general transformation: to NP and VP rules: 1.np(np(DT,NN)) --> dt(DT,Number), nn(NN,Number). 2.np(np(NP,PP)) --> np(NP), pp(PP). 3.vp(vp(VBD,NP)) --> vbd(VBD), np(NP). 4.vp(vp(VP,PP)) --> vp(VP), pp(PP). x(x(X,y)) --> x(X), [y]. x(x(z)) --> [z]. x(x(X,y)) --> x(X), [y]. x(x(z)) --> [z]. [z] [y] x x 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) --> [z], w(X,x(z)). x(x(z)) --> [z]. w(W,X) --> [y], w(W,x(X,y)). w(x(X,y),X) --> [y]. [z] [y] x x Note: w is a new Non-terminal That takes 2 arguments Note: w is a new Non-terminal That takes 2 arguments
19
Transformed grammar
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.