Top Banner
CSA4050: Advanced Topics in NLP Semantics IV • Partial Execution • Proper Noun • Transitive Verb Phrase
21

CSA4050: Advanced Topics in NLP

Jan 02, 2016

Download

Documents

travis-albert

CSA4050: Advanced Topics in NLP. Semantics IV Partial Execution Proper Noun Transitive Verb Phrase. Partial Execution. Partial execution involves the replacing of certain runtime computations with changes to the source of the Prolog program itself. - PowerPoint PPT Presentation
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: CSA4050: Advanced Topics in NLP

CSA4050:Advanced Topics in NLP

Semantics IV• Partial Execution• Proper Noun• Transitive Verb Phrase

Page 2: CSA4050: Advanced Topics in NLP

October 2004 CSA4050 Advanced NLP 2

Partial Execution

• Partial execution involves the replacing of certain runtime computations with changes to the source of the Prolog program itself.

• For example, we can replace the rule:s(S) --> np(NP), vp(VP) { reduce(NP,VP,S) }.withs(S) --> np(VP^S), vp(S).

• This is because the computation of reduce involves only the mutual binding of several variables.

Page 3: CSA4050: Advanced Topics in NLP

October 2004 CSA4050 Advanced NLP 3

How it works

s(S) --> np(NP), vp(VP) { reduce(NP,VP,S)}.

1. match reduce(A^F,A,F)

2. rewrite s(F) --> np(A^F), vp(A).

3. rename s(S) --> np(VP^S), vp(VP).

Page 4: CSA4050: Advanced Topics in NLP

October 2004 CSA4050 Advanced NLP 4

Exercise

• What is the result of eliminating the reduce clause by partial execution in the following rule?

np(NP) --> d(D), n(N), {reduce(D,N,NP)}.

Page 5: CSA4050: Advanced Topics in NLP

October 2004 CSA4050 Advanced NLP 5

Answer

np(NP) --> d(D), n(N) { reduce(D,N,NP)}.

1. match reduce(A^F,A,F)

2. rewrite np(F) --> d(A^F), n(A).

3. rename np(NP) --> d(N^NP), n(N).

Page 6: CSA4050: Advanced Topics in NLP

October 2004 CSA4050 Advanced NLP 6

DCG with QuantificationProgram 4

% grammars(S) --> np(VP^S), vp(VP).np(NP) --> d(N^NP), n(N).vp(VP) --> v(VP).

% lexiconv(X^walk(X)) --> [walks].n(X^man(X)) --> [man].n(suzie) --> [‘Suzie’].det(RL^SL^all(X,R,S) --> [every], {reduce(RL,X,R), reduce(SL,X,S) }.

Page 7: CSA4050: Advanced Topics in NLP

October 2004 CSA4050 Advanced NLP 7

Handling Proper Nouns

• The grammar handles every man walksX = all(_G, man(_G), walk(_G))

• Will this grammar parse Suzie walks?

• Let’s try it!

•?- s(X,['Suzie',walks],[ ]).

Page 8: CSA4050: Advanced Topics in NLP

October 2004 8

?- s(X,['Suzie',walks],[ ]).

Call: (8) s(_G492, ['Suzie', walks], []) ? Call: (9) np(_L183, ['Suzie', walks], _L184) ? Call: (10) pn(_L183, ['Suzie', walks], _L184) ? Exit: (10) pn(suzie, ['Suzie', walks], [walks]) ? Exit: (9) np(suzie, ['Suzie', walks], [walks]) ? Call: (9) vp(_L185, [walks], _L186) ? Call: (10) iv(_L185, [walks], _L186) ? Exit: (10) iv(_G556^walk(_G556), [walks], []) ? Exit: (9) vp(_G556^walk(_G556), [walks], []) ? Call: (9) reduce(suzie, _G556^walk(_G556), _G492) ? Fail: (9) reduce(suzie, _G556^walk(_G556), _G492)? ........

suzie is not a function

Page 9: CSA4050: Advanced Topics in NLP

October 2004 CSA4050 Advanced NLP 9

Handling Proper Nouns

• Problem is with the “type” of LF of Suzie.

• We require that LF of Suzie has the same type as any other NP - such as every man, i.e.– As a lambda expression it would be

λp.p(suzie). – In Prolog we can regard this as a function

from [VP] to [S] such that reduce(VP,john,S) holds.

Page 10: CSA4050: Advanced Topics in NLP

October 2004 CSA4050 Advanced NLP 10

DCG with QuantificationProgram 4

% grammars(S) --> np(VP^S), vp(VP).np(NP) --> n(NP).np(NP) --> d(N^NP), n(N).vp(VP) --> v(VP).

% lexiconv(X^walk(X)) --> [walks].n(X^man(X)) --> [man].n(VP^S) --> [‘Suzie’],

{reduce(VP,suzie,S)}.det(RL^SL^all(X,R => S) --> [every],

{reduce(RL,X,R), reduce(SL,X,S) }.

Page 11: CSA4050: Advanced Topics in NLP

October 2004 CSA4050 Advanced NLP 11

Exercise 2

Using partial execution, eliminate the reduce clause in

pn(VP^S) --> [‘Suzie’],{reduce(VP,suzie,S)}.

Page 12: CSA4050: Advanced Topics in NLP

October 2004 CSA4050 Advanced NLP 12

s(X, ['Suzie', walks], [ ]) ?

Call: (7) s(_G292, ['Suzie', walks], []) ? ↓Exit: (9) pn((suzie^_G357)^_G357, ['Suzie', walks], [walks]) ? ↓Exit: (9) iv(_G362^walk(_G362), [walks], []) ?Exit: (8) vp(_G362^walk(_G362), [walks], []) ?:Call: (8) reduce((suzie^_G357)^_G357, _G362^walk(_G362), _G292) ?:Exit: (8) reduce((suzie^walk(suzie))^walk(suzie), suzie^walk(suzie),

walk(suzie)) ? Exit: (7) s(walk(suzie), ['Suzie', walks], []) ? creep

X = walk(suzie)

Page 13: CSA4050: Advanced Topics in NLP

October 2004 CSA4050 Advanced NLP 13

Transitive Verb Phases

• Transitive verb phrases take an object, e.g.chased a cat

• To handle transitive VPs we need another VP rulevp(VP) --> v(V), np(NP).

• In this case we have:V = λx. λy. chased(x,y)NP = λs.some(w,cat(w),s(w))

• Issues:– What is the LF of the resulting VP and– How do the component LFs combine?

Page 14: CSA4050: Advanced Topics in NLP

October 2004 CSA4050 Advanced NLP 14

Resulting VP

λz.some(y,cat(y),chased(z,y))

• Note that this has the form of a standard VP that is waiting for a subject, so is compatible with the rest of the grammar.

Page 15: CSA4050: Advanced Topics in NLP

October 2004 CSA4050 Advanced NLP 15

Making VP

V

λx. λy. chased(x,y)

chased

NP

λs.some(w,cat(w),s(w))

some cat

VP

λz.some(y,cat(y),chased(z,y))

Page 16: CSA4050: Advanced Topics in NLP

October 2004 CSA4050 Advanced NLP 16

Apply NP to Vdoesn't work!

λs.some(w,cat(w), s(w)) (λx. λy. chased(x,y))

β

some(w,cat(w), (λy. λx. chased(x,y))(w))β

some(w,cat(w), λx.chased(x,w))

NP V

Page 17: CSA4050: Advanced Topics in NLP

October 2004 CSA4050 Advanced NLP 17

Solution

• Need a more complex way of combining V and NP: λNP.λV.λz.NP(V(z))

λs.some(w,cat(w), s(w)) ← NP arg

λx. λy. chased(x,y)) ← V arg

Page 18: CSA4050: Advanced Topics in NLP

October 2004 CSA4050 Advanced NLP 18

How it works

λNP.λV.λz.NP(V(z)) λs.some(w,cat(w), s(w)) λx. λy. chased(x,y))

λ z.λs.some(w,cat(w), s(w)) λx.λy.chased(x,y)(z) β

λ z.λs.some(w,cat(w), s(w)) (λy. chased(z,y)) β

λ z. some(cat(w), (λy.chased(z,y))(w)) β

λ z. some(cat(w), chased(z,w))

Page 19: CSA4050: Advanced Topics in NLP

October 2004 CSA4050 Advanced NLP 19

VP Rule Revisited

vp(VP) --> v(V), np(NP),

{instructions}.• The instructions encode the combination

λNP.λV.λz.NP(V(z)) vp(Z^P) --> v(V2), np(NP),

{reduce(V2,Z,V1),

reduce(NP,V1,P)}.

Page 20: CSA4050: Advanced Topics in NLP

October 2004 CSA4050 Advanced NLP 20

Program 5% grammars(S) --> np(NP), vp(VP), {reduce(NP,VP,S)}.np(NP) --> n(NP).np(NP) --> d(D), n(N), {reduce(D,N,NP) }.vp(VP) --> v(VP).vp(Z^P)--> v(V2), np(NP),

{reduce(V2,Z,V1), reduce(NP,V1,P)}.

% lexiconv(X^walk(X)) --> [walks].v(X^Y^chased(X,Y)) --> [chased].n(X^cat(X)) --> [cat].n(VP^S) --> [suzie], {reduce(VP,suzie,S)}.d(RL^SL^some(X,R,S)) --> [a],

{reduce(RL,X,R),reduce(SL,X,S) }.

Page 21: CSA4050: Advanced Topics in NLP

October 2004 CSA4050 Advanced NLP 21

Test

?- s(X,[suzie,chased,a,cat],[]).

X = some(_G245, cat(_G245), chased(suzie, _G245)) ?- s(X,[a,cat,chased,a,cat],[]).

X = some(_G245, cat(_G245), some(_G266, cat(_G266), chased(_G245, _G266))) ;