Presentation is loading. Please wait.

Presentation is loading. Please wait.

LING 388: Language and Computers Sandiway Fong Lecture 20: 11/3.

Similar presentations


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

1 LING 388: Language and Computers Sandiway Fong Lecture 20: 11/3

2 Administrivia Homework #3 –in yellow folder in my mailbox in Linguistics Douglass 216 Computer Laboratory Class: –today –homework #4 will handed out –due next Wednesday (November 10th) –email: by midnight to sandiway@email.arizona.edu

3 Last Time Predicate-argument structure mapping translator Idioms –e.g. VP kicked the bucket  VP died Japanese Grammar Japanese predicate- argument structure Japanese sentence English Grammar English predicate- argument structure English sentence p(A 1,A 2 ) Translator

4 Files FileDescriptionAlso contains e20.pl English DCG j20.pl Japanese DCGpredicate- argument code t.pl Translator/mappingbilingual dictionary

5 English Grammar: e20.pl DCG rules: sbar(PA) --> np(X,wh), do(_,_), s_objectwh(_,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)}. s(PA) --> np(Y,_), vp(Z,_), {predarg(Y,Z,1,PA)}. 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). vp(vp(v(died)),ed) --> [kicked,the,bucket]. vp(vp(Y,Z),F) --> transitive(Y,F), np(Z,_). vp(vp(A,V),F) --> aux(A,F), transitive(V,en). vp_objectwh(vp(Y)) --> transitive(Y,root). det(det(the),_) --> [the]. det(det(a),sg) --> [a]. common_noun(n(bucket),sg,notwh) --> [bucket]. common_noun(n(buckets),pl,notwh) --> [buckets]. common_noun(n(apple),sg,notwh) --> [apple]. common_noun(n(apples),pl,notwh) --> [apples]. common_noun(n(man),sg,notwh) --> [man]. common_noun(n(book),sg,notwh) --> [book]. common_noun(n(books),pl,notwh) --> [books]. pronoun(who,wh) --> [who]. pronoun(what,wh) --> [what]. proper_noun(john) --> [john]. transitive(v(eats),s) --> [eats]. transitive(v(ate),ed) --> [ate]. transitive(v(eaten),en) --> [eaten].

6 English Grammar: e20.pl transitive(v(buy),root) --> [buy]. transitive(v(buys),s) --> [buys]. transitive(v(bought),ed) --> [bought]. transitive(v(bought),en) --> [bought]. transitive(v(kicks),s) --> [kicks]. transitive(v(kicked),ed) --> [kicked]. transitive(v(kicked),en) --> [kicked]. aux(aux(was),ed) --> [was]. aux(aux(is),s) --> [is]. do(aux(does),s) --> [does]. do(aux(did),ed) --> [did].

7 Japanese Grammar: j20.pl DCG Rules: s(PA) --> 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]. predarg(X,Y,Order,PA) :- headof(X,S), headof(Y,P), order(Order,Y,NP), headof(NP,O), PA =.. [P,S,O]. predarg(X,Y,_,PA) :- headof(X,S), headof(Y,P), Y = vp(_), PA =.. [P,S]. order(1,vp(_,NP),NP). order(2,vp(NP,_),NP). headof(np(_,n(N)),N). headof(vp(v(V),_),V). headof(vp(_,v(V)),V). headof(vp(v(V)),V). headof(np(N),N). predicate-argument structure code: stored in j20.pl but used by both grammars

8 Translator: t.pl Prolog translation code: –translate(E,J) :-% Translator – sbar(X,E,[]), % English grammar – mapPA(X,Xp), – js(Xp,J,[]). % Japanese grammar –mapPA(E,J) :- % Map predicate-argument E =.. [P,S,O], je(PJ,P), je(SJ,S), je(OJ,O), J =.. [PJ,SJ,OJ]. –je(katta,bought).% Bilingual dictionary –je(hon,book). –je(taroo,john). –je(dare,who). –je(nani,what). –je(katta,buy).

9 Exercise 1: Translation Load files e20.pl, j20.pl and t.pl Exercises: 1.Verify each parser works individually by running the following sentences: John bought the books Taroo-ga hon-o katta 2.Verify the translator works by running Taroo-ga hon-o katta and see how many English translations are reported 3.Run the translator in reverse

10 Exercise 1: Translation Homework Question Using the debugger ( trace ) on the translator (or by other means) for the Japanese example: Taroo-ga hon-o katta (A) (1pt) How many English sentences are explored by the translator before a compatible sentence is found? (B) (2pts) How would you rewrite translate/2 to avoid this inefficiency for the Japanese -> English direction –Submit your definition of translate/2

11 Exercise 1: Translation Extra Credit Question –(C) On the number of translations –(C.1) (2pts) Why does ?- translate(X,[taroo,ga,hon,o,katta]). return duplicate answers? –(C.2) (3pts) Fix the problem Submit both your grammar and output

12 Exercise 2: Yes-No Questions Let’s add yes-no questions to the mix... Example: –Did John buy the books? –auxiliary do preceding subject signals the yes-no question Predicate-argument structure: –yesno(buy(john,books)) Example (Japanese): –Taroo-ga hon-o katta ka –ka = question particle Predicate-argument structure: –yesno(katta(taroo,hon))

13 Exercise 2: Yes-No Questions Example: –Did John buy the books? Predicate-argument structure: –yesno(buy(john,books)) One-line Implementation: –sbar(yesno(PA)) --> do(_,_), s(PA). –John buy the books –buy(john,books) –did John buy the books –yesno(buy(john,books)) Exercise: –Modify the English grammar to incorporate this rule –Verify its operation on the example sentence

14 Exercise 2: Yes-No Questions Example (Japanese): –Taroo-ga hon-o katta ka Predicate-argument structure: –yesno(katta(taroo,hon)) Homework Question (A) (3pts) –Implement the yes-no question for the Japanese grammar –Submit both your modified grammar and output –HINT: can be implemented in one rule...

15 Exercise 2: Yes-No Questions Example: –Did John buy a book? yesno(buy(john,book)) –Taroo-ga hon-o katta ka yesno(katta(taroo,hon)) Homework Question (B) (3pts) –Implement the translation for the example –Submit both your modified translator –HINT: can also be implemented by writing just one rule...

16 Exercise 3: English Idiom Example: –John kicked the bucket VP “kicked the bucket” –has a literal interpretation –has an idiomatic interpretation “John died” Idiomatic Interpretation: –Verb Phrase: kicked the bucket –vp(vp(v(died)) --> [kicked,the,bucket]. Verify Queries: –?- sbar(X,[john,kicked,the,bucket],[]). –X = died(john) ? ; –X = kicked(john,bucket) ? ; –?- sbar(X,[john,kicked,the,buckets],[]). –X = kicked(john,buckets) ? ; –no

17 Exercise 3: English Idiom Homework Question: –[The English side has already been implemented for you] –Implement the Japanese side of the grammar and the bilingual dictionary so that... –John kicked the bucket has both a literal and an idiomatic translation Taroo-ga buketsu-o ketta Taroo-ga shinda buketsu = bucket shinda = died –John kicked the buckets has only a literal translation Taroo-ga buketsu-o ketta (assuming Japanese does not distinguish number)

18 Exercise 3: English Idiom Homework Question: (A) Implement the Japanese sentences –submit the modified grammar and the predicate-argument output for the examples (A.1) (1pt) –Add the new noun buketsu to the grammar (A.2) (3pts) –Add the new verbs shinda and ketta to the grammar –You will need to add new rule(s) for handling intransitive shinda (A.3) (1pt) –Show your Japanese grammar works

19 Exercise 3: English Idiom Homework Question: –Implement the examples and the idiomatic translations (B) Implement the translation –submit the modified bilingual dictionary and the translator output for the examples (B.1) (2pt) –Add correspondences for pairs ( buketsu,bucket(s) ), ( shinda,died ) and ( ketta,kicked ) to the grammar (B.2) (2pts) –Show your translator works bidirectionally for the examples given

20 Exercise 4: Japanese Idiom Example: –Taroo-ga sensei-ni goma-o sutta –Taroo-nominative teacher-dative sesame-accusative grinded –“John flattered the teacher” –Taroo-ga Hanako-ni goma-o sutta –Taroo-nominative Hanako-dative sesame-accusative grinded –“John flattered Mary” –ni = dative Case marker Homework Question: –Implement the examples and the idiomatic translations

21 Exercise 4: Japanese Idiom Homework Question: –Implement the examples and the idiomatic translations (A) Implement the Japanese sentences –submit the modified grammar and the predicate-argument output for the examples (A.1) (1pt) –Add the new nouns hanako and sensei to the grammar (A.2) (3pts) –Add the new Case marker ni to the grammar –Add a new VP idiom rule for X-ni goma-o sutta (grinded sesame) –You may use: odateta as the Japanese counterpart for flattered (A.3) (1pt) –Show your Japanese grammar works

22 Exercise 4: Japanese Idiom Homework Question: –Implement the examples and the idiomatic translations (B) Implement the English gloss sentences –submit the modified grammar and the predicate-argument output for the examples (B.1) (1pt) –Add the new nouns mary and teacher to the grammar (B.2) (1pt) –Add the new verb flattered to the grammar (B.3) (1pt) –Show your English grammar works

23 Exercise 4: Japanese Idiom Homework Question: –Implement the examples and the idiomatic translations (C) Implement the translation –submit the modified bilingual dictionary and the translator output for the examples (C.1) (2pts) –Add correspondences for pairs ( hanako,mary ), ( odateta,flattered ) and ( sensei,teacher ) to the grammar (C.2) (2pts) –Show your translator works bidirectionally for the examples given

24 Homework Summary Question 1: Translation –3 pts –Extra Credit: 5 pts Question 2: Yes-No Questions –6 pts Question 3: English Idiom –9 pts Question 4: Japanese Idiom –12 pts Total: 30 pts

25 Next Time New topics No more programming...


Download ppt "LING 388: Language and Computers Sandiway Fong Lecture 20: 11/3."

Similar presentations


Ads by Google