Download presentation
Presentation is loading. Please wait.
1
CSA4050: Advanced Topics in NLP
Semantics IV Partial Execution Proper Noun Transitive Verb Phrase
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) }. with s(S) --> np(VP^S), vp(S). This is because the computation of reduce involves only the mutual binding of several variables. October 2004 CSA4050 Advanced NLP
3
How it works 1. match reduce(A^F,A,F) 2. rewrite 3. rename
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). 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)}. October 2004 CSA4050 Advanced NLP
5
Answer 1. match reduce(A^F,A,F) 2. rewrite 3. rename
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). October 2004 CSA4050 Advanced NLP
6
DCG with Quantification Program 4
% grammar s(S) --> np(VP^S), vp(VP). np(NP) --> d(N^NP), n(N). vp(VP) --> v(VP). % lexicon v(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) }. October 2004 CSA4050 Advanced NLP
7
Handling Proper Nouns ?- s(X,['Suzie',walks],[ ]).
The grammar handles every man walks X = all(_G, man(_G), walk(_G)) Will this grammar parse Suzie walks? Let’s try it! ?- s(X,['Suzie',walks],[ ]). October 2004 CSA4050 Advanced NLP
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 October 2004
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. October 2004 CSA4050 Advanced NLP
10
DCG with Quantification Program 4
% grammar s(S) --> np(VP^S), vp(VP). np(NP) --> n(NP). np(NP) --> d(N^NP), n(N). vp(VP) --> v(VP). % lexicon v(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) }. October 2004 CSA4050 Advanced NLP
11
Exercise 2 Using partial execution, eliminate the reduce clause in
pn(VP^S) --> [‘Suzie’],{reduce(VP,suzie,S)}. 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) 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 rule vp(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? October 2004 CSA4050 Advanced NLP
14
λz.some(y,cat(y),chased(z,y))
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. October 2004 CSA4050 Advanced NLP
15
λz.some(y,cat(y),chased(z,y))
Making VP VP λz.some(y,cat(y),chased(z,y)) V λx. λy. chased(x,y) chased NP λs.some(w,cat(w),s(w)) some cat October 2004 CSA4050 Advanced NLP
16
Apply NP to V doesn'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 October 2004 CSA4050 Advanced NLP
17
Solution λs.some(w,cat(w), s(w)) ← NP arg λx. λy. chased(x,y)) ← V arg
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 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)) 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)}. October 2004 CSA4050 Advanced NLP
20
Program 5 % grammar s(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)}. % lexicon v(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) }. 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],[]). some(_G266, cat(_G266), chased(_G245, _G266))) ; October 2004 CSA4050 Advanced NLP
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.