LING 388: Language and Computers Sandiway Fong Lecture 14 10/11.

25
LING 388: Language and Computers Sandiway Fong Lecture 14 10/11

Transcript of LING 388: Language and Computers Sandiway Fong Lecture 14 10/11.

Page 1: LING 388: Language and Computers Sandiway Fong Lecture 14 10/11.

LING 388: Language and Computers

Sandiway Fong

Lecture 14

10/11

Page 2: LING 388: Language and Computers Sandiway Fong Lecture 14 10/11.

Administrivia

• Homework 5 out today– Usual rules: due next Monday night

Page 3: LING 388: Language and Computers Sandiway Fong Lecture 14 10/11.

Tree Representation: Recap

• original DCG– sentence --> np, vp.– vp --> verb, np.– verb --> [took].– np --> det, [man].– np --> det, [book].– det --> [the].

• revised DCG: tree representation– sentence(s(NP,VP)) --> np(NP), vp(VP).– vp(vp(V,NP)) --> verb(V), np(NP).– verb(v(took)) --> [took].– np(np(D,man)) --> det(D), [man].– np(np(D,book)) --> det(D), [book].– det(det(the)) --> [the].

s(np(det(the),man),vp(v(took),np(det(the),man)))

• original query?- sentence(List,[]).• query (with an extra argument)?- sentence(P,List,[]).

– P = parse tree– List = sentence

Page 4: LING 388: Language and Computers Sandiway Fong Lecture 14 10/11.

Examples

• query– what parse P corresponds to the sentence “the man took the book”?– ?- sentence(P,[the,man,took,the,book],[]).– P = s(np(det(the),man),vp(v(took),np(det(the),book))) ? ;– no

• query– what are the possible parses P and word X for the sentence “the man took the X”?– ?- sentence(P,[the,man,took,the,X],[]).– P = s(np(det(the),man),vp(v(took),np(det(the),man))),– X = man ? ;– P = s(np(det(the),man),vp(v(took),np(det(the),book))),– X = book ? ;– no

Page 5: LING 388: Language and Computers Sandiway Fong Lecture 14 10/11.

Exercise 4 last time

• Idiom chunks– kicked the bucket

– has both a literal meaning (depicted on the right)

– and is also a VP (verb phrase) idiom– meaning: – died

Page 6: LING 388: Language and Computers Sandiway Fong Lecture 14 10/11.

Exercise 4 last time

• add new rule– “kicked the bucket” is a VP idiom meaning “died”– vp(vp(v(died))) --> [kicked,the,bucket].– example illustrates the ability to return any parse we like for a given rule

• query– what are the possible parses for “the man kicked the bucket”?– ?- sentence(Parse,[the,man,kicked,the,bucket],[]).– Parse = s(np(det(the),man),vp(v(died))) ? ;– no– idiomatic meaning only

• add new rules– for “kicked” and “bucket” as a verb and noun, respectively– verb(v(kicked)) --> [kicked].– np(np(D,bucket)) --> det(D), [bucket].– provides the ability to return the literal parse for “kicked the bucket” as well

Page 7: LING 388: Language and Computers Sandiway Fong Lecture 14 10/11.

Exercise 4 last time

• query– what are the possible parses for “the man kicked the bucket”?– ?- sentence(Parse,[the,man,kicked,the,bucket],[]).– Parse =

s(np(det(the),man),vp(v(kicked),np(det(the),bucket))) ? ;

– Parse = s(np(det(the),man),vp(v(died))) ? ;– no

– both idiomatic and literal meanings are now possible

– which one comes first? is preferred?

Page 8: LING 388: Language and Computers Sandiway Fong Lecture 14 10/11.

A Note on Encoding Idioms

• Our ability to handle the idiom neatly depends on the fact that the idiom is a constituent– this means we can encode it in just one rule

• Example:– “kicked the bucket” is a VP idiom meaning “died”– vp(vp(v(died))) --> [kicked,the,bucket].– very common... V + Object(s)– call it a day– jump the gun– walk the plank– turn the other cheek

• Asymmetry: Subject+V idioms are practically non-existent– The vultures appear to be circling NP [Linguist List, Vol-4-43]

sentence --> np, vp.vp --> verb, np.verb --> [took].np --> det, [man].np --> det, [book].det --> [the].

Page 9: LING 388: Language and Computers Sandiway Fong Lecture 14 10/11.

Extra Argument(s)

• used to hold the parse tree

• we can have multiple extra arguments in grammar rules

– there are other uses... e.g. agreement

Page 10: LING 388: Language and Computers Sandiway Fong Lecture 14 10/11.

Another Grammar

• example– s(s(Y,Z)) --> np(Y), vp(Z).– np(np(Y)) --> pronoun(Y).– np(np(det(the),n(ball))) --> [the,ball].– pronoun(i) --> [i].– pronoun(we) --> [we].– vp(vp(Y)) --> unergative(Y). – vp(vp(Y,Z)) --> transitive(Y), np(Z).– unergative(v(ran)) --> [ran].– transitive(v(hit)) --> [hit].

• query– ?- s(X,[john,hit,the,ball],[]).

Result: parse tree

Page 11: LING 388: Language and Computers Sandiway Fong Lecture 14 10/11.

Another Grammar

• example parsess

np vp

v np

det n

the ball

hit

i

s

np vp

v

ran

we

?- s(X,[we,ran],[]).

X = s(np(we),vp(v(ran)))?- s(X,[i,hit,the,ball],[]).X = s(np(i),vp(v(hit),np(det(the),n(ball))))

Page 12: LING 388: Language and Computers Sandiway Fong Lecture 14 10/11.

Determiner-Noun Agreement

• idea– we can also use the extra argument to enforce constraints between

constituents within a DCG rule• example

– English determiner-noun number agreement– data

• the man• the men• a man• *a men

– lexical features• man [singular]• men [plural]

Page 13: LING 388: Language and Computers Sandiway Fong Lecture 14 10/11.

Determiner-Noun Agreement

• data– the man/men– a man/*a men

• grammar– s(s(Y,Z)) --> np(Y), vp(Z).– np(np(Y)) --> pronoun(Y).– np(np(det(the),n(ball))) --> [the,ball].– pronoun(i) --> [i].– pronoun(we) --> [we].– vp(vp(Y)) --> unergative(Y). – vp(vp(Y,Z)) --> transitive(Y), np(Z).– unergative(v(ran)) --> [ran].– transitive(v(hit)) --> [hit].

np --> det, common_noun.det --> [the].det --> [a].common_noun--> [ball].common_noun--> [man].common_noun --> [men].

Page 14: LING 388: Language and Computers Sandiway Fong Lecture 14 10/11.

Determiner-Noun Agreement

• data– the man/men– a man/*a men

• grammar– s(s(Y,Z)) --> np(Y), vp(Z).– np(np(Y)) --> pronoun(Y).– np(np(det(the),n(ball))) --> [the,ball].– pronoun(i) --> [i].– pronoun(we) --> [we].– vp(vp(Y)) --> unergative(Y). – vp(vp(Y,Z)) --> transitive(Y), np(Z).– unergative(v(ran)) --> [ran].– transitive(v(hit)) --> [hit].

np --> det, common_noun.det --> [the].det --> [a].common_noun--> [ball].common_noun--> [man].common_noun --> [men].

np(np(D,N)) --> det(D), common_noun(N).det(det(the)) --> [the].det(det(a)) --> [a].common_noun(n(ball)) --> [ball].common_noun(n(man)) --> [man].common_noun(n(men)) --> [men].

Page 15: LING 388: Language and Computers Sandiway Fong Lecture 14 10/11.

Determiner-Noun Agreement

• data– the man/men– a man/*a men

• grammar– s(s(Y,Z)) --> np(Y), vp(Z).– np(np(Y)) --> pronoun(Y).– np(np(D,N)) --> det(D), common_noun(N).– det(det(the)) --> [the].– det(det(a)) --> [a].– common_noun(n(ball)) --> [ball].– common_noun(n(man)) --> [man].– common_noun(n(men)) --> [men].– pronoun(i) --> [i].– pronoun(we) --> [we].– vp(vp(Y)) --> unergative(Y). – vp(vp(Y,Z)) --> transitive(Y), np(Z).– unergative(v(ran)) --> [ran].– transitive(v(hit)) --> [hit].

• lexical features• man [singular]• men [plural]

• rules• the can combine with

singular or plural nouns

• a can combine only with singular nouns

Page 16: LING 388: Language and Computers Sandiway Fong Lecture 14 10/11.

Determiner-Noun Agreement

• data– the man/men– a man/*a men

• grammar (only the NP section shown here)– np(np(Y)) --> pronoun(Y).– np(np(D,N)) --> det(D), common_noun(N,Number).– det(det(the)) --> [the].– det(det(a)) --> [a].– common_noun(n(ball),sg) --> [ball].– common_noun(n(man),sg) --> [man].– common_noun(n(men),pl) --> [men].– pronoun(i) --> [i].– pronoun(we) --> [we].

• ideaspecify singular (sg) and plural (pl) for common nouns using an extra argument• rules

• the can combine with singular or plural nouns

• a can combine only with singular nouns

common_noun now takes two extra arguments:1. parse tree 2. number [sg,pl]Note: we therefore have to query common_noun with two extra arguments, e.g.common_noun(N,Number)

Page 17: LING 388: Language and Computers Sandiway Fong Lecture 14 10/11.

Determiner-Noun Agreement

• data– the man/men– a man/*a men

• grammar (NP section)– np(np(Y)) --> pronoun(Y).– np(np(D,N)) --> det(D,Number),

common_noun(N,Number).– det(det(the),sg) --> [the].– det(det(the),pl) --> [the].– det(det(a),sg) --> [a].– common_noun(n(ball),sg) --> [ball].– common_noun(n(man),sg) --> [man].– common_noun(n(men),pl) --> [men].– pronoun(i) --> [i].– pronoun(we) --> [we].

• idea• give determiners a

number feature as welland make it agree with the noun• rules

• the can combine with singular or plural nouns

• a can combine only with singular nouns

Page 18: LING 388: Language and Computers Sandiway Fong Lecture 14 10/11.

Determiner-Noun Agreement

• query– ?- np(X,[the,men],[]).– Note: we need not start with non-terminal symbol s, – i.e. parse a full sentence– Prolog DCG rules can be independently accessed

• computation tree – ?- np(X,[the,men],[]). X = np(D,N)

• ?- det(D,Number,[the,men],L).• ?- common_noun(N,Number,L,[]).

– ?- det(D,Number,[the,men],L). Rule #3• D = det(the) Number = sg L = [men]

– ?- common_noun(N,sg,[men],[]). Rule #8• No

– Retry (rule #3 led to failure)– ?- det(D,Number,[the,men],L). Rule #4

• D = det(the) Number = pl L = [men]– ?- common_noun(N,pl,[men],[]). Rule #8

• Yes N = n(men)

• X = np(det(the),n(men))

1. np(np(Y)) --> pronoun(Y).2. np(np(D,N)) --> det(D,Number),

common_noun(N,Number).3. det(det(the),sg) --> [the].4. det(det(the),pl) --> [the].5. det(det(a),sg) --> [a].6. common_noun(n(ball),sg) -->

[ball].7. common_noun(n(man),sg) -->

[man].8. common_noun(n(men),pl) -->

[men].9. pronoun(i) --> [i].10. pronoun(we) --> [we].

Page 19: LING 388: Language and Computers Sandiway Fong Lecture 14 10/11.

Determiner-Noun Agreement

• data– the man/men– a man/*a men

• query– ?- np(X,[a,men],[]).

• computation tree – ?- np(X,[a,men],[]). X = np(D,N)

• ?- det(D,Number,[a,men],L).• ?- common_noun(N,Number,L,[]).

– ?- det(D,Number,[a,men],L). Rule #5• D = det(a) Number = sg L = [men]

– ?- common_noun(N,sg,[men],[]). Rule #8• No

1. np(np(Y)) --> pronoun(Y).2. np(np(D,N)) --> det(D,Number),

common_noun(N,Number).3. det(det(the),sg) --> [the].4. det(det(the),pl) --> [the].5. det(det(a),sg) --> [a].6. common_noun(n(ball),sg) -->

[ball].7. common_noun(n(man),sg) -->

[man].8. common_noun(n(men),pl) -->

[men].9. pronoun(i) --> [i].10. pronoun(we) --> [we].

Page 20: LING 388: Language and Computers Sandiway Fong Lecture 14 10/11.

Determiner-Noun Agreement

• simplifying the grammardet(det(the),sg) --> [the].det(det(the),pl) --> [the].det(det(a),sg) --> [a].

• grammar is ambiguous– we have two rules for determiner the– can see the effect in the computation tree

• retry needed to get “the men” to parse• agreement rule (revisited):

• the can combine with singular or plural nouns• i.e. the doesn’t care about the number of the noun

• modified DCG• np(np(D,N)) --> det(D,Number), common_noun(N,Number).

– det(det(the),_) --> [the].

Note: _ is a variablea variable is used because it matches anything (sg,pl)used underscore character because I don’t care about the name of the variable

Page 21: LING 388: Language and Computers Sandiway Fong Lecture 14 10/11.

Determiner-Noun Agreement

• revisit query– ?- np(X,[the,men],[]).

• computation tree– ?- np(X,[the,men],[]). X = np(D,N)

• ?- det(D,Number,[the,men],L).• ?- common_noun(N,Number,L,[]).

– ?- det(D,Number,[the,men],L). Rule #3• D = det(the) Number = _ L = [men]

– ?- common_noun(N,_,[men],[]). Rule #7• Yes N = n(men) _ = pl

• X = np(det(the),n(men))

• a computational advantage– no need for retry (ambiguity removed)

1. np(np(Y)) --> pronoun(Y).2. np(np(D,N)) --> det(D,Number),

common_noun(N,Number).3. det(det(the),_) --> [the].4. det(det(a),sg) --> [a].5. common_noun(n(ball),sg) -->

[ball].6. common_noun(n(man),sg) -->

[man].7. common_noun(n(men),pl) -->

[men].8. pronoun(i) --> [i].9. pronoun(we) --> [we].

Page 22: LING 388: Language and Computers Sandiway Fong Lecture 14 10/11.

Homework 5

• Use the following grammar as a starting point

s(s(Y,Z)) --> np(Y), vp(Z).np(np(Y)) --> pronoun(Y).np(np(D,N)) --> det(D,Number), common_noun(N,Number).det(det(the),_) --> [the].det(det(a),sg) --> [a].common_noun(n(ball),sg) --> [ball].common_noun(n(man),sg) --> [man].common_noun(n(men),pl) --> [men].pronoun(i) --> [i].pronoun(we) --> [we].vp(vp(Y)) --> unergative(Y). vp(vp(Y,Z)) --> transitive(Y), np(Z).unergative(v(ran)) --> [ran].transitive(v(hit)) --> [hit].

Page 23: LING 388: Language and Computers Sandiway Fong Lecture 14 10/11.

Homework 5In English, determiners and Quantifiers interact with the Number system • Modify the grammar given to

handle:– every man hit the ball– *every men hit the ball

– *most man hit the ball– most men hit the ball

– some man hit the ball – some men hit the ball

– * (a) few man hit the ball– (a) few men hit the ball

– no man hit the ball– no men hit the ball

– one man hit the ball– *one men hit the ball

– *two man hit the ball– two men hit the ball

Page 24: LING 388: Language and Computers Sandiway Fong Lecture 14 10/11.

Homework 5

• Example:– every man hit the ball– *every men hit the ball

• Observation:– The quantifier every is compatible with singular count nouns but

not with plural ones– i.e. it seems to pattern like the determiner “a”

• a man hit the ball• *a men hit the ball

Submit your modified grammarand example runs for each case

Page 25: LING 388: Language and Computers Sandiway Fong Lecture 14 10/11.

Homework 5

Extra credit• Modify your grammar in

Homework 5 to handle mass nouns in conjunction with the quantifiers

• Submit the modified grammar and example runs

• Example: – mass term sand– I hit some sand– I hit sand– I hit the sand– *I hit a sand– *I hit one sand– *I hit two sands