140 likes | 230 Views
LING 388: Language and Computers. Sandiway Fong Lecture 17 10/20. Grammar from last time: Part 1. Grammar from last time: Part 2. Grammar from last time: Part 3. Today’s Tasks. Adding NP rules for proper nouns and bare plurals Subject-Verb Agreement. NP Modifications. Task 1
E N D
LING 388: Language and Computers Sandiway Fong Lecture 17 10/20
Today’s Tasks • Adding NP rules for proper nouns and bare plurals • Subject-Verb Agreement
NP Modifications • Task 1 • let’s add a proper noun rule • np(np(Y),sg) --> proper_noun(Y). • proper_noun(john) --> [john]. • load modified grammar into Prolog and test it • Example: ?- s(X,[the,ball,was,hit,by,john],[]). X = s(np(det(the),n(ball)),vp(vp(aux(was),v(hit)),pp(p(by),np(john)))) ? ; no • note that it doesn’t go into an infinite loop (despite the left recursion) • when you ask for more answers
NP Modifications • Task 2 • let’s add a bare plural noun rule • John eats dinners • John eats the dinners np(np(Y),pl) --> common_noun(Y,pl). • load modified grammar into Prolog and test it
The subject-verb agreement system is quite incomplete at the moment. Let’s fix this. s(s(Y,Z)) --> np(Y,Number), vp(Z,Number). vp(vp(Y),_Number) --> unergative(Y). vp(vp(Y,Z),Number) --> transitive(Y,Form), np(Z,_), {Form = s -> Number = sg ; true}. vp(vp(A,V),Number) --> aux(A,Number), transitive(V,en). transitive(v(eats),s) --> [eats]. Subject-Verb Agreement
Test examples John eats dinners *I eats dinners *We eats dinners He eats dinners They eat dinners dinners were eaten *dinners was eaten *The dinner were eaten The dinner was eaten Let’s modify the grammar to constrain this properly: -s form of the verb is compatible with 3rd person singular only for the subject NP was is compatible with singular subject NPs were is compatible with plural subject NPs s(s(Y,Z)) --> np(Y,Number), vp(Z,Number). vp(vp(Y),_Number) --> unergative(Y). vp(vp(Y,Z),Number) --> transitive(Y,Form), np(Z,_), {Form = s -> Number = sg ; true}. vp(vp(A,V),Number) --> aux(A,Number), transitive(V,en). transitive(v(eats),s) --> [eats]. Subject-Verb Agreement We need the subject NP to report Number and Person We need all verbs to report the inflectional ending form
Modified rules for the NP system Summary Pronouns must report number and person features These features must in turn be reported by NP NP rules therefore have 3 extra arguments: (1) parse tree, (2) number, and (3) person Every reference to NP in the grammar needs to have 3 extra arguments Subject-Verb Agreement
Modified rules for the VP Summary verbs must report the inflectional Ending feature the VP nonterminal must have 3 extra arguments to report: (1) parse tree, (2) number, and (3) inflection Subject-Verb Agreement
Subject-Verb Agreement • Regular endings are: • root, s, ing, ed, en • Since the auxiliary verb be is irregular, we report the inflectional ending as the verb form itself • was, were
Subject-Verb Agreement Agreement implemented: • -s form of the verb is compatible with 3rd person singular only for the subject NP • was is compatible with singular subject NPs • were is compatible with plural subject NPs not a non-terminal, but a call to Prolog predicate checkSubjVerb/3 the if-then-else Prolog programming construct is used here. • If -> Then ; Else • Note: • Nesting is used ( • true is always true (always succeeds)
Code • Final version of the grammar for today is available for download at the course website: • Filename: g17.pl