250 likes | 384 Views
LING 388: Language and Computers. Sandiway Fong Lecture 29. Today’s Topic. Finally, a working translator… Relevant files: g29.pl English grammar j29.pl Japanese grammar translator29.pl translator (the “glue”). Last Time.
E N D
LING 388: Language and Computers Sandiway Fong Lecture29
Today’s Topic • Finally, a working translator… • Relevant files: • g29.pl English grammar • j29.pl Japanese grammar • translator29.pl translator (the “glue”)
Last Time • We made extensive modifications to the English grammar to convert it to produce predicate-argument structures instead of syntax trees …
Last Time • Passives:
Last Time • Object wh-question:
Last Time • Subject wh-question: • wh-question + passive:
Last Time • Subject-auxiliary verb inversion: yes-no question:
g29.pl • Three cases: • Examples: • What did John buy • whnpdosupportnpvp_objwh • Who bought a book • whnpempty_npvp • What was bought by John • whnpempty_npvp_passive
g29.pl • Two cases: • Examples: • Did John buy a book • dosupportnpvp • Was a book bought by John • v_auxnpvp_auxraised
g29.pl • Two cases: • Examples: • John bought a book • npvp • a book was bought by John • npvp_passive
g29.pl • Conversion table: Ending TENSE (morpheme) Needed when TENSE and the main verb are separated • Example: a book was bought by John • Ending V+vbn • vbd_sgbuy+vbn V+TENSE buy+past
g29.pl • Conversion table: Ending TENSE (morpheme) • Example: was a book bought by John • Ending V+vbn • vbd_sgbuy+vbn V+TENSE buy+past
g29.pl • Conversion table: Ending TENSE (morpheme) • Example: what was bought by John • Ending V+vbn • vbd_sgbuy+vbn V+TENSE buy+past
g29.pl • The English grammar must also work in generation mode:
g29.pl • Parse: • Generate sentence from predicate-argument structure:
g29.pl • Prevent infinite loop during generation: • comment out relative clause NP rules
g29.pl • Parse: • Generate sentence from predicate-argument structure:
Modules • To operate the translator, we must load in both grammars simultaneously but keep them separate. • Symbol naming problem: • we have separate grammar rules for our two languages, some of them share the same names, e.g. np, nn, vp etc. • SWI Prolog supports namespaces called modules first line of code in the file
Modules • Japanese module:
Modules • Translator (translator29.pl): tells Prolog to load the English grammar not a grammar rule, Prolog code (: - )
Exercise 1 • Use e2j(E,J) to translate the Japanese sentence taroo-gahon-o kaimashita • what happens? • (how many parses do we get?)
Exercise 2 • Use e2j(E,J) to translate the Japanese sentence taroo-gahon-o kaimashita • hon can mean book or books • How would you modify the translate table to get both forms?
Exercise 3 • English passive sentence a book was bought doesn’t translate (yet) • Why not? • Hint: add to the translate table
Exercise 4 • Modify the translate table to make these wh-questions work: • Who bought a book? • What did John buy? • Dare-gahon-o kaimashitaka • Nani-o taroo-gakaimashitaka
Exercise 5 • Do yes/no-questions work in the translator? • Did John buy a book? • Was a book bought by John? • Taroo-gahon-o kaimashitaka