230 likes | 443 Views
LING 388: Language and Computers. Sandiway Fong Lecture 18: 10/27. Administrivia. Computer Laboratory Problem : planning a lab class next Wednesday another class has reserved the SBSRI lab at the time we need for most of the month of November Two potential solutions :
E N D
LING 388: Language and Computers Sandiway Fong Lecture 18: 10/27
Administrivia • Computer Laboratory Problem: • planning a lab class next Wednesday • another class has reserved the SBSRI lab • at the time we need • for most of the month of November • Two potential solutions: • schedule the class at a non-regular class time • do the computer lab as a lecture here • I walk you through the exercises on my laptop • no hands-on work though (unless you bring a laptop)
Last Time • Database Facts (Correspondences): • je(v(katta), v(bought)). • je(np(hon), np(_,n(book))). • je(np(taroo), np(john)). • je(np(dare), np(taroo)). • Example 1 (Declarative case): • John bought a book s(np(john),vp(v(bought),np(det(a),n(book)))) • Taroo-ga hon-o katta s(np(taroo),vp(np(hon),v(katta))) • Queries: • ?- translate([john,bought,a,book],J). J = [taroo,ga,hon,o,katta] • ?- translate(E,[taroo,ga,hon,o,katta]). E = [john,bought,the,book] • Example 2 (Subject wh-Question): • Who bought a book s(np(who),vp(v(bought),np(det(a),n(book)))) • dare-ga hon-o katta ka s(np(dare),vp(np(hon),v(katta))) • Queries: • ?- translate([who,bought,a,book],J). J = [dare,ga,hon,o,katta,ka] • ?- translate(E,[dare,ga,hon,o,katta,ka]). E = [who,bought,the,book]
Today’s Topics • Object wh-question case ... • An alternative to tree-to-tree mapping • using predicate-argument structure
Japanese: Grammar • DCG rules: • s(s(Y,Z)) --> np(Y,Q1), nomcase, vp(Z,Q2), sf(Q1,Q2). • vp(vp(Z,Y),Q) --> np(Z,Q), acccase, transitive(Y). • transitive(v(katta)) --> [katta]. • nomcase --> [ga]. • acccase --> [o]. • np(np(taroo),notwh) --> [taroo]. • np(np(hon),notwh) --> [hon]. • np(np(dare),wh) --> [dare]. • np(np(nani),wh) --> [nani]. • sf(wh,notwh) --> [ka]. • sf(notwh,wh) --> [ka]. • sf(notwh,notwh) --> []. • sf(wh,wh) --> [ka].
Japanese: Grammar • DCG rules: • js(s(Y,Z)) --> jnp(Y,Q1), nomcase, jvp(Z,Q2), sf(Q1,Q2). • jvp(vp(Z,Y),Q) --> jnp(Z,Q), acccase, jtransitive(Y). • jtransitive(v(katta)) --> [katta]. • nomcase --> [ga]. • acccase --> [o]. • jnp(np(taroo),notwh) --> [taroo]. • jnp(np(hon),notwh) --> [hon]. • jnp(np(dare),wh) --> [dare]. • jnp(np(nani),wh) --> [nani]. • sf(wh,notwh) --> [ka]. • sf(notwh,wh) --> [ka]. • sf(notwh,notwh) --> []. • sf(wh,wh) --> [ka]. Japanese nonterminals renamed to avoid clash with the English grammar – we’re going to be loading them both at the same time
DCG rules: sbar(sbar(X,A,Y)) --> np(X,wh), do(A), s_objectwh(Y). sbar(S) --> s(S). s_objectwh(s(Y,Z)) --> np(Y,_), vp_objectwh(Z). s(s(Y,Z)) --> np(Y,_), vp(Z). np(np(Y),Q) --> pronoun(Y,Q). np(np(Y),notwh) --> proper_noun(Y). np(np(D,N),Q) --> det(D,Number), common_noun(N,Number,Q). det(det(the),_) --> [the]. det(det(a),sg) --> [a]. common_noun(n(ball),sg,notwh) --> [ball]. common_noun(n(man),sg,notwh) --> [man]. common_noun(n(men),pl,notwh) --> [men]. common_noun(n(book),sg,notwh) --> [book]. pronoun(who,wh) --> [who]. pronoun(what,wh) --> [what]. pronoun(i,notwh) --> [i]. pronoun(we,notwh) --> [we]. pronoun(me,notwh) --> [me]. proper_noun(john) --> [john]. vp(vp(Y)) --> unergative(Y). vp(vp(Y,Z)) --> transitive(Y,_), np(Z,_). vp(vp(A,V)) --> aux(A), transitive(V,en). vp_objectwh(vp(Y)) --> transitive(Y,root). unergative(v(ran)) --> [ran]. transitive(v(hit),_) --> [hit]. transitive(v(eat),root) --> [eat]. transitive(v(eats),s) --> [eats]. transitive(v(ate),ed) --> [ate]. transitive(v(eaten),en) --> [eaten]. transitive(v(buy),root) --> [buy]. transitive(v(bought),ed) --> [bought]. aux(aux(was)) --> [was]. do(aux(did)) --> [did]. do(aux(does)) --> [does]. do(aux(do)) --> [do]. English: Grammar
Grammar and Computation • Both DCGs are flexible: • We can parse • We can also generate • We can even enumerate • Examples: • ?- sbar(X,[john,bought,a,book],[]). • X = s(np(john),vp(v(bought),np(det(a),n(book)))) • ?- sbar(s(np(john),vp(v(bought),np(det(a),n(book)))),Y,[]). • Y = [john,bought,a,book] • ?- sbar(X,E,[]). • E = [who,did,who,hit], • X = sbar(np(who),aux(did),s(np(who),vp(v(hit)))) ? ; • E = [who,did,who,eat], • X = sbar(np(who),aux(did),s(np(who),vp(v(eat)))) ? ;
Example 3 • Object wh-Question: • What did John buy sbar(np(what),aux(did),s(np(john),vp(v(buy)))) • taroo-ga nani-o katta ka s(np(taroo),vp(np(nani),v(katta))) • ka = question particle • ga = nominative case marker • o = accusative case marker • New Word Correspondences: • nani = what • Database facts: • je(v(katta), v(bought)). • je(np(hon), np(_,n(book))). • je(np(taroo),np(john)). • je(np(dare), np(who)). • je(np(nani), np(what)).
Example 3 • Object wh-Question: • What did John buy sbar(np(what),aux(did),s(np(john),vp(v(buy)))) • taroo-ga nani-o katta ka s(np(taroo),vp(np(nani),v(katta))) • Database facts: • je(v(katta), v(bought)). • je(np(hon), np(_,n(book))). • je(np(taroo),np(john)). • je(np(dare), np(who)). • je(np(nani), np(what)). • Can our translation code so far handle this case? • i.e. can maptree/2 do the job? • translate(E,J) :- • sbar(X,E,[]), • maptree(X,Xp), • js(Xp,J,[]). • maptree(s(S,vp(V,O)),s(SJ,vp(OJ,VJ))) :- • je(SJ,S), • je(VJ,V), • je(OJ,O).
Example 3 • Object wh-Question: • What did John buy sbar(np(what),aux(did),s(np(john),vp(v(buy)))) • taroo-ga nani-o katta ka s(np(taroo),vp(np(nani),v(katta))) • Database facts: • je(v(katta), v(bought)). • je(np(hon), np(_,n(book))). • je(np(taroo),np(john)). • je(np(dare), np(who)). • je(np(nani), np(what)). • je(v(katta), v(buy)). % Simplification • Can maptree/2 do the job? • maptree(s(S,vp(V,O)),s(SJ,vp(OJ,VJ))) :- • je(SJ,S), • je(VJ,V), • je(OJ,O). • maptree(sbar(O,_,s(S,vp(V))),s(SJ,vp(OJ,VJ))) :- • je(SJ,S), • je(VJ,V), • je(OJ,O).
Partial Summary • That’s essentially the tree-to-tree mapping approach • (linguistic) construction-based • A more abstract approach • mapping via predicate-argument structure
Mapping: Predicate-Argument Structure • [Lecture 14 revisited] • Predicate-Argument Structure • simpler representation than a parse tree • abstraction of the parse tree representation • picking out only the content word heads of each phrase • Example: • i hit the ball • Query: • ?- sbar(X, [i,hit,the,ball], []). • X = s(np(i),vp(v(hit),np(det(the),n(ball)))) • Modified grammar to produce: • ?- sbar(X, [i,hit,the,ball], []). • X = hit(i,ball)
Mapping: Predicate-Argument Structure • Modify: • s(s(X,Y)) --> np(X), vp(Y). • Modification: • s(PA) --> np(X), vp(Y), {predarg(X,Y,PA)}. • Connecting Code: • predarg(X,Y,PA) :- • headof(X,S), • headof(Y,P), • Y=vp(_,NP), • headof(NP,O), • PA =.. [P,S,O]. • Head-Of Relation in Prolog: • headof(np(_,n(N)),N). • headof(vp(v(V),_),V). • headof(np(N),N).
Mapping: Tree-to-tree • Tree-to-tree • requires a complex maptree/2 definition • because of the different parse tree shapes • Example 1 (Declarative case): • John bought a book s(np(john),vp(v(bought),np(det(a),n(book)))) • Taroo-ga hon-o katta s(np(taroo),vp(np(hon),v(katta))) • Example 2 (Subject wh-Question): • Who bought a book s(np(who),vp(v(bought),np(det(a),n(book)))) • dare-ga hon-o katta ka s(np(dare),vp(np(hon),v(katta))) • Example 3 (Object wh-Question): • What did John buy sbar(np(what),aux(did),s(np(john),vp(v(buy)))) • taroo-ga nani-o katta ka s(np(taroo),vp(np(nani),v(katta)))
Mapping: Predicate-Argument Structure • Predicate-argument • much more simple mapping • also the correspondence dictionary will be more simple too • Example 1 (Declarative case): • John bought a book bought(john,book) • Taroo-ga hon-o katta katta(taroo,hon) • Example 2 (Subject wh-Question): • Who bought a book bought(who,book) • dare-ga hon-o katta ka katta(dare,hon) • Example 3 (Object wh-Question): • What did John buy bought(john,what) • taroo-ga nani-o katta ka katta(taroo,nani)
Mapping: Predicate-Argument Structure • Task 1: • Modify the Japanese grammar to also generate predicate argument structure • DCG rules: • s(s(Y,Z)) --> np(Y,Q1), nomcase, vp(Z,Q2), sf(Q1,Q2). • vp(vp(Z,Y),Q) --> np(Z,Q), acccase, transitive(Y). • transitive(v(katta)) --> [katta]. • nomcase --> [ga]. • acccase --> [o]. • np(np(taroo),notwh) --> [taroo]. • np(np(hon),notwh) --> [hon]. • np(np(dare),wh) --> [dare]. • np(np(nani),wh) --> [nani]. • sf(wh,notwh) --> [ka]. • sf(notwh,wh) --> [ka]. • sf(notwh,notwh) --> []. • sf(wh,wh) --> [ka].
Mapping: Predicate-Argument Structure • Task 1: • Modify the Japanese grammar to also generate predicate argument structure • Modified DCG rules: • s(PA) --> np(Y,Q1), nomcase, vp(Z,Q2), sf(Q1,Q2), { predarg(Y,Z,PA)}. • vp(vp(Z,Y),Q) --> np(Z,Q), acccase, transitive(Y). • transitive(v(katta)) --> [katta]. • nomcase --> [ga]. • acccase --> [o]. • np(np(taroo),notwh) --> [taroo]. • np(np(hon),notwh) --> [hon]. • np(np(dare),wh) --> [dare]. • np(np(nani),wh) --> [nani]. • sf(wh,notwh) --> [ka]. • sf(notwh,wh) --> [ka]. • sf(notwh,notwh) --> []. • sf(wh,wh) --> [ka].
Mapping: Predicate-Argument Structure • Task 1: • Modify the Japanese grammar to also generate predicate argument structure • predarg/3: • make it language-independent, i.e. parameterize it with respect to word-order • predarg(X,Y,PA) :- • headof(X,S), • headof(Y,P), • Y=vp(_,NP), % for vp(V,NP) order only • headof(NP,O), • PA =.. [P,S,O]. • Modified predarg/4: • predarg(X,Y,Order,PA) :- • headof(X,S), • headof(Y,P), • object(Order,Y,NP), • headof(NP,O), • PA =.. [P,S,O]. • order(1,vp(_,NP),NP). % English word-order • order(2,vp(NP,_),NP). % Japanese word-order
Mapping: Predicate-Argument Structure • Task 1: • Modify the Japanese grammar to also generate predicate argument structure • DCG Rule: • s(PA) --> np(Y,Q1), nomcase, vp(Z,Q2), sf(Q1,Q2), {predarg(Y,Z,PA)}. • Modified DCG Rule: • s(PA) --> np(Y,Q1), nomcase, vp(Z,Q2), sf(Q1,Q2), {predarg(Y,Z,2,PA)}. • Modified English DCG Rule: • s(PA) --> np(X), vp(Y), { predarg(X,Y,1,PA)}. • Head-Of Relation: • originally defined for English only • now works for Japanese word-order as well • headof(np(_,n(N)),N). • headof(vp(v(V),_),V). • headof(vp(_,v(V)),V). % Japanese word order • headof(np(N),N).
Mapping: Predicate-Argument Structure • Examples : • Taroo-ga hon-o katta katta(taroo,hon) • dare-ga hon-o katta ka katta(dare,hon) • taroo-ga nani-o katta ka katta(taroo,nani) • can now be accounted for using the following • DCG Rules: • s(s(Y,Z)) --> np(Y,Q1), nomcase, vp(Z,Q2), sf(Q1,Q2), {predarg(Y,Z,2,PA)}. • vp(vp(Z,Y),Q) --> np(Z,Q), acccase, transitive(Y). • transitive(v(katta)) --> [katta]. • nomcase --> [ga]. • acccase --> [o]. • np(np(taroo),notwh) --> [taroo]. • np(np(hon),notwh) --> [hon]. • np(np(dare),wh) --> [dare]. • np(np(nani),wh) --> [nani]. • sf(wh,notwh) --> [ka]. • sf(notwh,wh) --> [ka]. • sf(notwh,notwh) --> []. • sf(wh,wh) --> [ka].
Mapping: Predicate-Argument Structure • Task 2: • Modify the English grammar to also generate predicate argument structure • Modified English DCG Rule: • s(PA) --> np(X), vp(Y), { predarg(X,Y,1,PA)}. • Applies to: • John bought a book bought(john,book) • Who bought a book bought(who,book) • SBar rules: • sbar(sbar(X,A,Y)) --> np(X,wh), do(A), s_objectwh(Y). • sbar(S) --> s(S). • s_objectwh(s(Y,Z)) --> np(Y,_), vp_objectwh(Z). • vp_objectwh(vp(Y)) --> transitive(Y,root). • Example 3 (Object wh-Question): • What did John buy bought(john,what)
Mapping: Predicate-Argument Structure • Task 2: • Modify the English grammar to also generate predicate argument structure • Example 3 (Object wh-Question): • What did John buy bought(john,what) • Modified SBar rules: • sbar(PA) --> np(X,wh), do(A), s_objectwh(Y,S,P), {headof(X,O),PA =.. [P,S,O]}. • sbar(S) --> s(S). • s_objectwh(s(Y,Z),S,P) --> np(Y,_), vp_objectwh(Z), {headof(Y,S),headof(Z,P)}. • vp_objectwh(vp(Y)) --> transitive(Y,root).