410 likes | 549 Views
LING 388: Language and Computers. Sandiway Fong Lecture 22. Exercise 4 from last week. Extra Credit Homework 7 review. Exercise 4 from last week. will / shall can be prepended to express a future event: He will eat the sandwich * He will ate the sandwich He will be eating the sandwich
E N D
LING 388: Language and Computers Sandiway Fong Lecture 22
Exercise 4 from last week • Extra Credit Homework 7 review
Exercise 4 from last week will/shall can be prepended to express a future event: • He will eat the sandwich • *He will ate the sandwich • He will be eating the sandwich • He will have eaten the sandwich • He will have been eating the sandwich • The sandwich will be eaten • The sandwich will have been eaten • The sandwich will have been being eaten • will/shall morphologically constrains following verb to have Ending vb (uninflected form)
Exercise 4 from last week will,shall don’t inflect
Exercise 4 from last week • Examples:
Exercise 4 from last week • Examples:
Exercise 4 from last week • Examples:
Exercise 4 from last week • Examples:
Exercise 4 from last week • Examples:
Exercise 4 from last week • Examples:
PP by-Phrase • Modify the v_aux rule rule associated with passive be: • PP phrase is optional:
PP by-Phrase • Rules: Parses:
PP by-Phrase • Following the Stanford Parser’s phrase structure: acc • The sandwich had been eaten by me/him/*I/*he
Case Constraint • Basic system: • Subjects must have nom Case • Objects must have acc Case • Implementation: • All NPs report Case values (nom/acc/_) • NPs in all subject positions restricted to nom • NPs in all objects positions restricted to acc
Case Constraint • Implementation: • All NPs report Case values (nom/acc/_Case)
Case Constraint • Implementation: • NPs in all subject positions restricted to nom • Doesn’t work in all situations… • I want him/*he to win the race
Case Constraint • Example: I want him to win the race acc
Case Constraint • Implementation: • NPs in all objects positions restricted to acc
New Topic • Let’s write a grammar for simple Japanese
Japanese • head-final language • sentence word order (canonical) • Subject Object Verb (Japanese) • Subject Verb Object (English) • example • John bought a book (English) • John a book bought (Japanese word order) • Taroo-gahon-okaimashita(Japanese) • case markers • ga = nominative case marker • o = accusative case marker • note: no determiner present in the Japanese sentence
Japanese • head-final language • 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) • Example • John bought a book (English) • John a book bought • Taroo-gahon-okaimashita (Japanese - canonical) • hon-oTaroo-gakaimashita (Japanese - scrambled) • *Taroo-gakaimashitahon-o (English word order) • ga = nominative case marker • o = accusative case marker
Japanese example • John bought a book • John a book bought • taroo-gahon-o kaimashita • ga = nominative • case marker • o = accusative • case marker • Parser input • (as a Prolog list with case particles separated) • [taroo,ga,hon,o,kaimashita] • Example grammar rules 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]. • note: • new nonterminalsnomcaseacccasedo not create structure • order of np, transitive in the VP reflects Japanese word order
Japanese 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]. • example • John a book bought • taroo-gahon-okaimashita • ga = nominative case marker • o = accusative case marker • computation tree • ?-s(X,[taroo,ga,hon,o,kaimashita],[]). • ?- np(Y,[taroo,ga,hon,o,kaimashita],L1). • ?- nomcase(L1,L2). • ?- vp(Z,L2,[]). • ?- np(Y,[taroo,ga,hon,o,kaimashita],L1). • Y = np(taroo) L1 = [ga,hon,o,kaimashita] • ?- nomcase([ga,hon,o,kaimashita],L2). • L2 = [hon,o,kaimashita] • ?-vp(vp(Z’,Y’), [hon,o,kaimashita],[]). Z = vp(Z’,Y’) • ?- np(Z’,[hon,o,kaimashita],L1’). • ?- acccase(L1’,L2’). • ?- transitive(Y’,L2’,[]).
Japanese 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]. • example • John a book bought • taroo-gahon-okaimashita • ga = nominative case marker • o = accusative case marker • computation tree • ?-vp(vp(Z’,Y’), [hon,o,kaimashita],[]). • ?- np(Z’,[hon,o,kaimashita],L1’). • ?- acccase(L1’,L2’). • ?- transitive(Y’,L2’,[]). • ?- np(Z’,[hon,o,kaimashita],L1’) • Z’ = np(hon) L1’ = [o,kaimashita] • ?- acccase([o,kaimashita],L2’). • L2’ = [kaimashita] • ?-transitive(Y’,[kaimashita],[]). • Y’ = v(kaimashita) • answer • ?-s(X,[taroo,ga,hon,o,kaimashita],[]). • X = s(np(taroo), vp(np(hon), v(kaimashita)))
Parser Sentence Parse tree Generator Sentence Parse tree Japanese 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]. • example John a book bought taroo-gahon-okaimashita ga = nominative case marker o = accusative case marker • grammar • can be run “backwards” for sentence generation • we’ll need this • query • ?-s(s(np(taroo), vp(np(hon), v(kaimashita))),L,[]). • L = [taroo, ga, hon, o,kaimashita]
Japanese 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]. • example John a book bought taroo-gahon-okaimashita • 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,L1). • ?- nomcase(L1,L2). • ?- vp(vp(np(hon),v(kaimashita))),L2,[]). • ?- np(np(taroo),L,L1). • L = [taroo|L1] • ?- nomcase(L1,L2). • L1 = [ga|L2] • ?- vp(vp(np(hon),v(kaimashita))),L2,[]). • Z’ = np(hon) Y’ = v(kaimashita) • ?- np(np(hon),L2,L3). • ?- acccase(L3,L4). • ?- transitive(v(kaimashita),L4,[]).
Japanese 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]. • example • John a book bought • taroo-gahon-okaimashita • query (generation) • ?- vp(vp(np(hon),v(kaimashita))),L2,[]). • Z’ = np(taroo) Y’ = v(kaimashita) • ?- np(np(hon),L2,L3). • ?- acccase(L3,L4). • ?- transitive(v(kaimashita),L4,[]). • ?- np(np(hon),L2,L3). • L2 = [hon|L3] • ?- acccase(L3,L4). • L3 = [o|L4] • ?- transitive(v(kaimashita),L4,[]). • L4 = [kaimashita|[]]
Japanese 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]. • example • John a book bought • taroo-gahon-okaimashita • query (generation) • back-substituting ... • ?- np(np(taroo),L,L1). • L = [taroo|L1] • ?- nomcase(L1,L2). • L1 = [ga|L2] • ?- np(np(hon),L2,L3). • L2 = [hon|L3] • ?- acccase(L3,L4). • L3 = [o|L4] • ?- transitive(v(kaimashita),L4,[]). • L4 = [kaimashita|[]] • answer • L = [taroo, ga, hon, o,kaimashita]
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:
Japanese • wh-NP phrases • English • 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”) • boughtbuy (untensed form) what did John buy what did John bought what John bought John bought what John bought a book
Japanese • wh-NP phrases • English • Who bought a book? (subject wh-phrase) • *John bought what? (only possible as an echo-question) • What did John buy? (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-ganani-okaimashitaka • nani: means what • ka: sentence-final question particle • dare-gahon-okaimashitaka • dare: means who register differences: ka or no?
Japanese • wh-in-situ: • taroo-ganani-okaimashitaka • nani: means what • ka: sentence-final question particle • dare-gahon-okaimashitaka • 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-ganani-okaimashitaka • dare-gahon-okaimashitaka • 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]. • np(np(dare)) --> [dare]. • np(np(nani)) --> [nani]. • allows sentences • Taroo-gahon-okaimashita • Taroo-ganani-o kaimashita (ka) • dare-gahon-okaimashita (ka) Assuming for simplicity that a sentence-final particle is required for wh-questions… How to enforce the constraint that ka is obligatory when a wh-phrase is in the sentence?
Japanese • wh-in-situ: • taroo-ganani-okaimashitaka • dare-gahon-okaimashitaka • 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-ganani-okaimashitaka • dare-gahon-okaimashitaka • grammar • s(s(Y,Z)) --> np(Y,Q1), nomcase, vp(Z,Q2). • 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 whfor nouns • propagate this feature up to the (top) sentence rule • means adding extra argument Q to the VP nonterminal
Japanese • wh-in-situ: • taroo-ganani-okaimashitaka • dare-gahon-okaimashitaka • grammar • 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(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 whfor 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 sentence-final particle rule (sf/2) sf(wh,notwh) --> [ka]. sf(notwh,wh) --> [ka]. sf(notwh,notwh) --> []. (empty) sf(wh,wh) --> [ka]. • wh-in-situ: • taroo-ganani-okaimashitaka • dare-gahon-okaimashitaka • grammar • 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(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 whfor 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-ganani-o kaimashitaka (who bought what)
Japanese we may want to modifiy the parse tree to represent the sentence-final particle ka as well • wh-in-situ: • taroo-ganani-okaimashitaka • dare-gahon-okaimashitaka • 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,Q1), nomcase, vp(Z,Q2), sf(Q1,Q2). 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,wh) --> [ka]. sf(notwh,notwh) --> []. sf(wh,wh) --> [ka].
Appendix Alternative implementations… • so far, we used: • s(s(Y,Z)) --> np(Y,Q1), nomcase, vp(Z,Q2), sf(Q1,Q2). • could have written (equivalently) • s(s(Y,Z)) --> np(Y,notwh), nomcase, vp(Z,notwh). • s(s(Y,Z)) --> np(Y,Q1), nomcase, vp(Z,Q2), {\+ Q1=notwh ; \+ Q2=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,Q1), nomcase, vp(Z,Q2), {\+ Q1=notwh ; \+ Q2=notwh}, sf. • sf --> [ka]. • generates different structures for declarative vs. wh-NP questions