Upload
erica-terry
View
225
Download
0
Embed Size (px)
Citation preview
LING 388: Language and Computers
Sandiway Fong
Lecture 20: 11/3
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
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(A1,A2)
Translator
Files
File Description Also contains
e20.pl English DCG
j20.pl Japanese DCG predicate-argument code
t.pl Translator/mapping bilingual dictionary
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].
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].
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
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).
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
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
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
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))
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
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 ...
Exercise 2: Yes-No Questions
• Example:– Did John buy a book? yesno(buy(john,book)) – Taroo-ga hon-o katta kayesno(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 ...
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
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)
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
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
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
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
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
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
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
Next Time
• New topics
• No more programming ...