Presentation is loading. Please wait.

Presentation is loading. Please wait.

LING 388: Language and Computers Sandiway Fong Lecture 23 11/10.

Similar presentations


Presentation on theme: "LING 388: Language and Computers Sandiway Fong Lecture 23 11/10."— Presentation transcript:

1 LING 388: Language and Computers Sandiway Fong Lecture 23 11/10

2 Last Time English wh-questions –subject wh-questions: simple –object wh-questions: complex wh-word fronting do-support tense goes with do DCG technology employed –extra argument –nonterminal renaming s[objectwh] np vp [objectwh] v sbar np what buy john aux did np trace

3 Grammar g22.pl s(S) vp(Z,Ending)

4 Grammar g22.pl

5

6

7 Exercise 1 Modify the grammar to employ Wh-movement for both subject and object wh-questions i.e. be able to generate the following structures: –[ Sbar Who [ S [ NP trace] [ VP bought [ NP a book]]]] –[ Sbar What did [ S [ NP John] [ VP buy [ NP trace]]]] Implemented last time Exercise 1

8 Given –[ Sbar Who [ S [ NP trace] [ VP bought [ NP a book]]]] need grammar rules: 1.Sbar  wh-NP S (with subject trace) 2.S (with subject trace)  VP

9 Exercise 1 Interrogatives are Sbar trees and declaratives are S trees. Define parse/2 as follows: Need to block wh-word in subject position to avoid generating the S trees for Who bought a book?

10 Exercise 1 Add call to checkQ/3 for declarative S grammar rule:

11 Exercise 2 grammar components so far: –English DCG –Japanese DCG –both are bi-directional can generate and parse with the same grammar advantage of using Prolog for that putting it all together into the same file... –our first attempt at Machine Translation (MT) putting it all together into the same file... –our first attempt at Machine Translation (MT)

12 Japanese: Data Declarative –Taroo-ga hon-o katta –John a book bought ga = nominative case marker o = accusative case marker Wh-questions –Taroo-ga nani-o katta ka nani: means what ka: sentence-final question particle –dare-ga hon-o katta ka dare: means who 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].

13 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]. rename Japanese nonterminals to not clash with English grammar – we’re going to be loading them both at the same time

14 English: Data Declarative: –John bought a book Wh-Questions: –Who bought a book?(subject wh-phrase) –*John bought what?(only possible as an echo-question) –What did John buy?(object wh-phrase)

15 English: Grammar We can also generate with this grammar –like with the Japanese grammar Examples: –?- s(s(np(john),vp(v(bought),np(det(a),n(book)))),Y,[]). –Y = [john,bought,a,book] –?- sbar(sbar(np(what),aux(did),s(np(john),vp(v(buy)))),Y,[]). –Y = [what,did,john,buy] –?- sbar(s(np(who),vp(v(bought),np(det(a),n(book)))),Y,[]). –Y = [who,bought,a,book]

16 Example 1 declarative example –John bought a book –Taroo-ga hon-o katta word correspondences –katta = bought –hon = book –Taroo  John –ga = nominative case marker –o = accusative case marker database facts –je(katta,bought). –je(hon,book). –je(taroo,john).

17 Example 1 declarative example –John bought a book –Taroo-ga hon-o katta database facts –je(katta,bought). –je(hon,book). –je(taroo,john). parse trees –?- s(X,[john,bought,a,book],[]). –X = s(np(john),vp(v(bought),np(det(a),n(book)))) –?- js(X,[taroo,ga,hon,o,katta],[]). –X = s(np(taroo),vp(np(hon),v(katta))) translator (top-level): –?- s(X,EnglishSentence,[]),maptree(X,Y),js(Y,JapaneseSentence,[]). –problem reduces to: how to write predicate maptree/2 ?

18 Example 1 declarative example –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))) database facts (modified) –je(katta,bought). je(v(katta),v(bought)). –je(hon,book).je(np(hon),np(det(_),n(book))). % no corresponding indefinite determiner in Japanese –je(taroo,john).je(np(taroo),np(john)). predicate maptree/2 –idea: map subject to subject, verb to verb, object to object, and respect word-order differences in the trees –maptree(s(S,vp(V,O)),s(SJ,vp(OJ,VJ))) :- je(SJ,S), je(VJ,V), je(OJ,O).

19 Example 1 declarative example –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))) predicate maptree/2

20 Example 1 declarative example –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))) query (E  J) –?- translate([john,bought,a,book],J). –J = [taroo,ga,hon,o,katta] query (J  E) –?- translate(E,[taroo,ga,hon,o,katta]). –E = [john,bought,the,book](surprising!) computation tree (J  E) –?- translate(E,[taroo,ga,hon,o,katta]). ?- sbar(X,E,[]). ?- maptree( X,Xp). ?- js(Xp,[taroo,ga,hon,o,katta],[]). What does the query ?- sbar( X,E,[]). do? X represents the parse tree E represents the input sentence but both arguments are variables! i.e. we’re not providing any information to the English grammar/parser What does the query ?- sbar( X,E,[]). do? X represents the parse tree E represents the input sentence but both arguments are variables! i.e. we’re not providing any information to the English grammar/parser


Download ppt "LING 388: Language and Computers Sandiway Fong Lecture 23 11/10."

Similar presentations


Ads by Google