Download presentation
Presentation is loading. Please wait.
1
LING 438/538 Computational Linguistics Sandiway Fong Lecture 22: 11/15
2
Context-free Grammars back to DCGs next homework: –write a phrase structure grammar for a fragment of English Textbook: –Phrase structure grammars are covered in Chapter 9
3
Recall: Chomsky Hierarchy Regular Grammars FSA Regular Expressions DCG = Type-0 Type-3 Type-2 = Context-free Type-1 = Context-sensitive from lecture5
4
Definite Clause Grammars Basic Technology already covered earlier in the course See: –Lecture 5: Basic definition of a DCG –Lecture 6: Left and right recursion. Prolog’s Computation Rule –Lecture 7: Adding an extra argument to non-terminals to generate a parse tree for grammatical sentences –Lecture 9: Adding extra arguments to non-terminals to enforce agreement between constituents
5
Introduction to Context-free grammars Basically (in DCG format): –LHS --> RHS. –LHS = single non-terminal –RHS = a sequence of zero or more terminal or non- terminals (possibly mixed) –non-terminals may contain extra arguments, e.g. np(NP,Case,Number,Person)
6
Exercise Let’s write a context-free grammar that returns parse trees for simple active/passive sentence pairs such as: –John hit a ball/John ate a sandwich –*John hit/John ate –*hit a ball/*ate a sandwich –the ball was hit/the sandwich was eaten –the ball was hit by John/the sandwich was eaten by John Let’s introduce traces in the case of passives: –[ S [ NP the ball] [ VP [aux was ][ VP [ V hit] [ NP trace]]]] –[ S [ NP the ball] [ VP [ VP [aux was ][ VP [ V hit] [ NP trace]]][ PP [ P by][ NP John]]]]
7
Grammar Note: –need to handle English passive morphology –passive be selects for a V-en Example –*was ate (simple past form) –was eaten (-en past participle form) Implementation: –use an extra argument to indicate the verb form –v(v(ate),past) --> [ate]. –v(v(eaten),pastparticiple) --> [eaten].
8
Grammar [Developed in class] s(s(NP,VP)) --> np(NP,notrace), vp(VP,_,_,notrace). np(np(Det,N),notrace) --> det(Det), common_noun(N). np(np(N),notrace) --> proper_noun(N). np(np(trace),trace) --> []. proper_noun(john) --> [john]. det(det(the)) --> [the]. det(det(a)) --> [a]. common_noun(n(ball)) --> [ball]. common_noun(n(sandwich)) --> [sandwich]. vp(vp(BE,VP),Form,selectsforvp,no trace) --> passive_be(BE,Form), vp(VP,pastparticiple,transitive,tr ace). vp(vp(V,NP),Form,transitive,EC) --> transitive(V,Form), np(NP,EC). vp(vp(V),Form,intransitive,notrace) --> intransitive(V,Form). vp(vp(VP,PP),Form,transitive,EC) - -> vp(VP,Form,transitive,EC), pp(PP).
9
Grammar passive_be(v(be),root) --> [be]. passive_be(v(is),thirdpersonpresen t) --> [is]. passive_be(v(was),past) --> [was]. intransitive(v(eat),root) --> [eat]. intransitive(v(eats),s) --> [eats]. intransitive(v(ate),past) --> [ate]. intransitive(v(eaten),pastparticiple) --> [eaten]. transitive(v(eat),root) --> [eat]. transitive(v(eats),s) --> [eats]. transitive(v(ate),past) --> [ate]. transitive(v(eaten),pastparticiple) -- > [eaten]. transitive(v(hit),root) --> [hit]. transitive(v(hits),s) --> [hits]. transitive(v(hit),past) --> [hit]. transitive(v(hit),pastparticiple) --> [hit]. pp(pp(P,NP)) --> p(P), np(NP,notrace). p(p(by)) --> [by].
10
Grammatical Sentences ?- s(X,[john,hit,the,ball],[]). X = s(np(john),vp(v(hit),np(det(the),n(ball)))) | ?- s(X,[john,ate,a,sandwich],[]). X = s(np(john),vp(v(ate),np(det(a),n(sandwich)))) | ?- s(X,[john,ate],[]). X = s(np(john),vp(v(ate))) | ?- s(X,[the,sandwich,was,eaten],[]). X = s(np(det(the),n(sandwich)),vp(v(was),vp(v(eaten),np(trace)))) | ?- s(X,[the,sandwich,was,eaten,by,john],[]). X = s(np(det(the),n(sandwich)),vp(v(was),vp(vp(v(eaten),np(trace)),pp(p( by),np(john)))))
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.