LING 388 Language and Computers Sandiway Fong Lecture

  • Slides: 32
Download presentation
LING 388: Language and Computers Sandiway Fong Lecture 22

LING 388: Language and Computers Sandiway Fong Lecture 22

Review of g 21. pl • g 21. pl is the latest English grammar

Review of g 21. pl • g 21. pl is the latest English grammar we've developed so far …

g 21. pl

g 21. pl

g 21. pl

g 21. pl

g 21. pl

g 21. pl

g 21. pl All subject NPs have a nom Case constraint

g 21. pl All subject NPs have a nom Case constraint

g 21. pl % am % are

g 21. pl % am % are

g 21. pl All VP object NPs have an acc Case constraint

g 21. pl All VP object NPs have an acc Case constraint

g 21. pl PP object NPs also have an acc Case constraint

g 21. pl PP object NPs also have an acc Case constraint

g 21. pl

g 21. pl

New Topic • Let’s write a grammar for simple Japanese

New Topic • Let’s write a grammar for simple Japanese

Japanese • head-final language – sentence word order (canonical) • Subject Object Verb •

Japanese • head-final language – sentence word order (canonical) • Subject Object Verb • Subject Verb Object (Japanese) (English) • example – – John bought a book John a book bought Taroo-ga hon-o kaimashita case markers (English) (Japanese word order) (Japanese) • ga = nominative case marker • o = accusative case marker – note: no determiner present in the Japanese sentence

Japanese • head-final language • Example – sentence word order (canonical) • Subject Object

Japanese • head-final language • Example – sentence word order (canonical) • Subject Object Verb – Japanese also allows “scrambling” • e. g. object and subject can be switched in order • Subject Object Verb • Object Subject Verb • *Subject Verb Object (must still be head-final) – John bought a book (English) – John a book bought – Taroo-ga hon-o kaimashita (Japanese - canonical) – hon-o Taroo-ga kaimashita (Japanese - scrambled) – *Taroo-ga kaimashita hon-o (English word order) – ga = nominative case marker – o = accusative case marker

Japanese example • Parser input • John bought a book – (as a Prolog

Japanese example • Parser input • John bought a book – (as a Prolog list with case particles separated) • John a book bought– [taroo, ga, hon, o, kaimashita] • taroo-ga hon-o kaimashita • Example grammar rules • • ga = nominative case marker o = accusative case marker note: s(s(Y, Z)) --> np(Y), nomcase, vp(Z). vp(vp(Z, Y)) --> np(Z), acccase, transitive(Y). transitive(v(kaimashita)) --> [kaimashita]. nomcase --> [ga]. acccase --> [o]. np(np(taroo)) --> [taroo]. np(np(hon)) --> [hon]. • new nonterminals nomcase acccase do not create structure • order of np, transitive in the VP reflects Japanese word order

Japanese • example – – John a book bought taroo-ga hon-o kaimashita ga =

Japanese • example – – John a book bought taroo-ga hon-o kaimashita ga = nominative case marker o = accusative case marker 1. 2. 3. 4. 5. 6. 7. s(s(Y, Z)) --> np(Y), nomcase, vp(Z). vp(vp(Z, Y)) --> np(Z), acccase, transitive(Y). transitive(v(kaimashita)) --> [kaimashita]. nomcase --> [ga]. acccase --> [o]. np(np(taroo)) --> [taroo]. np(np(hon)) --> [hon]. • computation tree – ? - s(X, [taroo, ga, hon, o, kaimashita], []). • • • ? - np(Y, [taroo, ga, hon, o, kaimashita], L 1). ? - nomcase(L 1, L 2). ? - vp(Z, L 2, []). – ? - np(Y, [taroo, ga, hon, o, kaimashita], L 1). • Y = np(taroo) L 1 = [ga, hon, o, kaimashita] – ? - nomcase([ga, hon, o, kaimashita], L 2). • L 2 = [hon, o, kaimashita] – ? - vp(vp(Z’, Y’), [hon, o, kaimashita], []). Z = vp(Z’, Y’) • • • ? - np(Z’, [hon, o, kaimashita], L 1’). ? - acccase(L 1’, L 2’). ? - transitive(Y’, L 2’, []).

Japanese • example – – • John a book bought taroo-ga hon-o kaimashita ga

Japanese • example – – • John a book bought taroo-ga hon-o kaimashita ga = nominative case marker o = accusative case marker 1. 2. 3. 4. 5. 6. 7. s(s(Y, Z)) --> np(Y), nomcase, vp(Z). vp(vp(Z, Y)) --> np(Z), acccase, transitive(Y). transitive(v(kaimashita)) --> [kaimashita]. nomcase --> [ga]. acccase --> [o]. np(np(taroo)) --> [taroo]. np(np(hon)) --> [hon]. computation tree – ? - vp(vp(Z’, Y’), [hon, o, kaimashita], []). • • • ? - np(Z’, [hon, o, kaimashita], L 1’). ? - acccase(L 1’, L 2’). ? - transitive(Y’, L 2’, []). – ? - np(Z’, [hon, o, kaimashita], L 1’) • Z’ = np(hon) L 1’ = [o, kaimashita] – ? - acccase([o, kaimashita], L 2’). • L 2’ = [kaimashita] – ? - transitive(Y’, [kaimashita], []). • • answer Y’ = v(kaimashita) – ? - s(X, [taroo, ga, hon, o, kaimashita], []). – X = s(np(taroo), vp(np(hon), v(kaimashita)))

Japanese • example John a book bought taroo-ga hon-o kaimashita ga = nominative case

Japanese • example John a book bought taroo-ga hon-o kaimashita ga = nominative case marker o = accusative case marker 1. 2. 3. 4. 5. 6. 7. s(s(Y, Z)) --> np(Y), nomcase, vp(Z). vp(vp(Z, Y)) --> np(Z), acccase, transitive(Y). transitive(v(kaimashita)) --> [kaimashita]. nomcase --> [ga]. acccase --> [o]. np(np(taroo)) --> [taroo]. np(np(hon)) --> [hon]. • grammar – can be run “backwards” for sentence generation – we’ll need this • query Sentence Parser Parse tree Sentence Generator Parse tree – ? - s(s(np(taroo), vp(np(hon), v(kaimashita))), L, []). – L = [taroo, ga, hon, o, kaimashita]

Japanese • example John a book bought taroo-ga hon-o kaimashita 1. 2. 3. 4.

Japanese • example John a book bought taroo-ga hon-o kaimashita 1. 2. 3. 4. 5. 6. 7. s(s(Y, Z)) --> np(Y), nomcase, vp(Z). vp(vp(Z, Y)) --> np(Z), acccase, transitive(Y). transitive(v(kaimashita)) --> [kaimashita]. nomcase --> [ga]. acccase --> [o]. np(np(taroo)) --> [taroo]. np(np(hon)) --> [hon]. • query (generation) – – – ? - s(s(np(taroo), vp(np(hon), v(kaimashita))), L, []). • Y = np(taroo) Z = vp(np(hon), v(kaimashita))) • ? - np(np(taroo), L, L 1). • ? - nomcase(L 1, L 2). • ? - vp(vp(np(hon), v(kaimashita))), L 2, []). ? - np(np(taroo), L, L 1). • L = [taroo|L 1] ? - nomcase(L 1, L 2). • L 1 = [ga|L 2] – ? - vp(vp(np(hon), v(kaimashita))), L 2, []). • • Z’ = np(hon) Y’ = v(kaimashita) ? - np(np(hon), L 2, L 3). ? - acccase(L 3, L 4). ? - transitive(v(kaimashita), L 4, []).

Japanese • example – John a book bought – taroo-ga hon-o kaimashita • 1.

Japanese • example – John a book bought – taroo-ga hon-o kaimashita • 1. 2. 3. 4. 5. 6. 7. s(s(Y, Z)) --> np(Y), nomcase, vp(Z). vp(vp(Z, Y)) --> np(Z), acccase, transitive(Y). transitive(v(kaimashita)) --> [kaimashita]. nomcase --> [ga]. acccase --> [o]. np(np(taroo)) --> [taroo]. np(np(hon)) --> [hon]. query (generation) – ? - vp(vp(np(hon), v(kaimashita))), L 2, []). • Z’ = np(taroo) Y’ = v(kaimashita) • ? - np(np(hon), L 2, L 3). • ? - acccase(L 3, L 4). • ? - transitive(v(kaimashita), L 4, []). – ? - np(np(hon), L 2, L 3). • L 2 = [hon|L 3] – ? - acccase(L 3, L 4). • L 3 = [o|L 4] – ? - transitive(v(kaimashita), L 4, []). • L 4 = [kaimashita|[]]

Japanese • example – John a book bought – taroo-ga hon-o kaimashita • 1.

Japanese • example – John a book bought – taroo-ga hon-o kaimashita • 1. 2. 3. 4. 5. 6. 7. query (generation) – back-substituting. . . – ? - np(np(taroo), L, L 1). • L = [taroo|L 1] – ? - nomcase(L 1, L 2). • L 1 = [ga|L 2] – ? - np(np(hon), L 2, L 3). • L 2 = [hon|L 3] – ? - acccase(L 3, L 4). • L 3 = [o|L 4] – ? - transitive(v(kaimashita), L 4, []). • • L 4 = [kaimashita|[]] answer – L = [taroo, ga, hon, o, kaimashita] s(s(Y, Z)) --> np(Y), nomcase, vp(Z). vp(vp(Z, Y)) --> np(Z), acccase, transitive(Y). transitive(v(kaimashita)) --> [kaimashita]. nomcase --> [ga]. acccase --> [o]. np(np(taroo)) --> [taroo]. np(np(hon)) --> [hon].

Scrambling • Idea: – object moves (i. e. “scrambled”) to the front of the

Scrambling • Idea: – object moves (i. e. “scrambled”) to the front of the sentence – leaves a trace behind in canonical object position – adjoins to S • Implementation:

Scrambling • Result:

Scrambling • Result:

Japanese • wh-NP phrases – English what did John buy bought what a book

Japanese • wh-NP phrases – English what did John buy bought what a book – examples • John bought a book • Who bought a book? (subject wh-phrase) • *John bought what? (echo-question only) • What did John buy? (object wh-phrase) • object wh-phrase case – complex operation required from the declarative form: » object wh-phrase must be fronted » do-support (insertion of past tense form of “do”) » bought buy (untensed form)

Japanese • wh-NP phrases – English • Who bought a book? • *John bought

Japanese • wh-NP phrases – English • Who bought a book? • *John bought what? • What did John buy? (subject wh-phrase) (only possible as an echo-question) (object wh-phrase) – Japanese • wh-in-situ: – meaning wh-phrase appears in same position as a regular noun phrase – easy to implement!(no complex series of operations) • taroo-ga nani-o kaimashita ka – nani: means what – ka: sentence-final question particle • dare-ga hon-o kaimashita ka – dare: means who register differences: ka or no?

Japanese • wh-in-situ: – taroo-ga nani-o kaimashita ka • nani: means what • ka:

Japanese • wh-in-situ: – taroo-ga nani-o kaimashita ka • nani: means what • ka: sentence-final question particle – dare-ga hon-o kaimashita ka • dare: means who • grammar • – – – – s(s(Y, Z)) --> np(Y), nomcase, vp(Z). vp(vp(Z, Y)) --> np(Z), acccase, transitive(Y). transitive(v(kaimashita)) --> [kaimashita]. nomcase --> [ga]. acccase --> [o]. np(np(taroo)) --> [taroo]. np(np(hon)) --> [hon]. add new wh-words – np(np(dare)) --> [dare]. – np(np(nani)) --> [nani].

Japanese • wh-in-situ: • • – taroo-ga nani-o kaimashita ka – dare-ga hon-o kaimashita

Japanese • wh-in-situ: • • – taroo-ga nani-o kaimashita ka – dare-ga hon-o kaimashita ka grammar – – – – – s(s(Y, Z)) --> np(Y), nomcase, vp(Z). vp(vp(Z, Y)) --> np(Z), acccase, transitive(Y). transitive(v(kaimashita)) --> [kaimashita]. nomcase --> [ga]. acccase --> [o]. Assuming for simplicity that a sentence-final np(np(taroo)) --> [taroo]. particle is required for wh-questions… np(np(hon)) --> [hon]. np(np(dare)) --> [dare]. np(np(nani)) --> [nani]. allows sentences – Taroo-ga hon-o kaimashita – Taroo-ga nani-o kaimashita (ka) – dare-ga hon-o kaimashita (ka) How to enforce the constraint that ka is obligatory when a wh-phrase is in the sentence?

Japanese • wh-in-situ: – taroo-ga nani-o kaimashita ka – dare-ga hon-o kaimashita ka •

Japanese • wh-in-situ: – taroo-ga nani-o kaimashita ka – dare-ga hon-o kaimashita ka • grammar – – – – – s(s(Y, Z)) --> np(Y, Q), nomcase, vp(Z). vp(vp(Z, Y)) --> np(Z, Q), acccase, transitive(Y). transitive(v(kaimashita)) --> [kaimashita]. nomcase --> [ga]. acccase --> [o]. np(np(taroo), notwh) --> [taroo]. np(np(hon), notwh) --> [hon]. np(np(dare), wh) --> [dare]. np(np(nani), wh) --> [nani]. • answer – employ extra argument to encode the lexical feature wh (e. g with values wh, notwh) for nouns

Japanese • wh-in-situ: • • – taroo-ga nani-o kaimashita ka – dare-ga hon-o kaimashita

Japanese • wh-in-situ: • • – taroo-ga nani-o kaimashita ka – dare-ga hon-o kaimashita ka grammar – – – – – s(s(Y, Z)) --> np(Y, Q 1), nomcase, vp(Z, Q 2). vp(vp(Z, Y), Q) --> np(Z, Q), acccase, transitive(Y). transitive(v(kaimashita)) --> [kaimashita]. nomcase --> [ga]. acccase --> [o]. np(np(taroo), notwh) --> [taroo]. np(np(hon), notwh) --> [hon]. np(np(dare), wh) --> [dare]. np(np(nani), wh) --> [nani]. answer – employ an extra argument to encode the lexical feature wh for nouns – propagate this feature up to the (top) sentence rule • means adding extra argument Q to the VP nonterminal

Japanese • wh-in-situ: • • – taroo-ga nani-o kaimashita ka – dare-ga hon-o kaimashita

Japanese • wh-in-situ: • • – taroo-ga nani-o kaimashita ka – dare-ga hon-o kaimashita ka grammar – – – – – s(s(Y, Z)) --> np(Y, Q 1), nomcase, vp(Z, Q 2), sf(Q 1, Q 2). vp(vp(Z, Y), Q) --> np(Z, Q), acccase, transitive(Y). transitive(v(kaimashita)) --> [kaimashita]. nomcase --> [ga]. acccase --> [o]. np(np(taroo), notwh) --> [taroo]. np(np(hon), notwh) --> [hon]. np(np(dare), wh) --> [dare]. np(np(nani), wh) --> [nani]. answer – employ an extra argument to encode the lexical feature wh for nouns – propagate this feature up to the (top) sentence rule • means adding extra argument Q to the VP nonterminal – add a sentence-final particle rule (sf) that generates ka when this feature is wh

Japanese • wh-in-situ: • • – taroo-ga nani-o kaimashita ka – dare-ga hon-o kaimashita

Japanese • wh-in-situ: • • – taroo-ga nani-o kaimashita ka – dare-ga hon-o kaimashita ka grammar – – – – – sentence-final particle rule (sf/2) sf(wh, notwh) --> [ka]. sf(notwh, notwh) --> []. sf(wh, wh) --> [ka]. (empty) s(s(Y, Z)) --> np(Y, Q 1), nomcase, vp(Z, Q 2), sf(Q 1, Q 2). vp(vp(Z, Y), Q) --> np(Z, Q), acccase, transitive(Y). transitive(v(kaimashita)) --> [kaimashita]. nomcase --> [ga]. acccase --> [o]. np(np(taroo), notwh) --> [taroo]. np(np(hon), notwh) --> [hon]. np(np(dare), wh) --> [dare]. np(np(nani), wh) --> [nani]. answer – employ an extra argument to encode the lexical feature wh for nouns – propagate this feature up to the (top) sentence rule • means adding extra argument Q to the VP nonterminal – add a sentence-final particle rule (sf) that generates ka when this feature is wh sf(wh, wh) --> [ka]. example: dare-ga nani-o kaimashita ka (who bought what)

Japanese • wh-in-situ: – taroo-ga nani-o kaimashita ka – dare-ga hon-o kaimashita ka •

Japanese • wh-in-situ: – taroo-ga nani-o kaimashita ka – dare-ga hon-o kaimashita ka • computation tree – – ? - s(X, [taroo, ga, nani, o, kaimashita, ka], []). X = s(np(taroo), vp(np(nani), v(kaimashita))) ? - s(X, [taroo, ga, nani, o, kaimashita], []). false s(s(Y, Z)) --> np(Y, Q 1), nomcase, vp(Z, Q 2), sf(Q 1, Q 2). vp(vp(Z, Y), Q) --> np(Z, Q), acccase, transitive(Y). transitive(v(kaimashita)) --> [kaimashita]. 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, notwh) --> []. sf(wh, wh) --> [ka]. we may want to modifiy the parse tree to represent the sentence-final particle ka as well

Appendix Alternative implementations… • so far, we used: – s(s(Y, Z)) --> np(Y, Q

Appendix Alternative implementations… • so far, we used: – s(s(Y, Z)) --> np(Y, Q 1), nomcase, vp(Z, Q 2), sf(Q 1, Q 2). • could have written (equivalently) – s(s(Y, Z)) --> np(Y, notwh), nomcase, vp(Z, notwh). – s(s(Y, Z)) --> np(Y, Q 1), nomcase, vp(Z, Q 2), {+ Q 1=notwh ; + Q 2=notwh }, sf. – sf --> [ka]. • or (also equivalently) – s(s(Y, Z)) --> np(Y, notwh), nomcase, vp(Z, notwh). – s(s(Y, Z, ka)) --> np(Y, Q 1), nomcase, vp(Z, Q 2), {+ Q 1=notwh ; + Q 2=notwh }, sf. – sf --> [ka]. – generates different structures for declarative vs. wh-NP questions