- Ch. 9 Linking Syntax and Semantics
1
Linking Syntax and Semantics
- Introduction
- Semantics Interpretation and
Compositionality
- A Simple Grammar with Semantic
Linking Syntax and Semantics Introduction Semantics Interpretation - - PowerPoint PPT Presentation
Linking Syntax and Semantics Introduction Semantics Interpretation and Compositionality A Simple Grammar with Semantic Interpretation Ch. 9 Linking Syntax and Semantics 1 Introduction Semantic analysis follows syntactic
1
2
3
4
5
structure: – e.g., syntax: s vp np np name v art n John (loves (every dog))
Every d: (DOG1 d) (LOVES1 I1 (NAME j1 “John”) d))
(LOVES1 I1 (NAME j1 “John”)<EVERY d DOG1>)
6
they may be combined to give the expression above?
e.g., ``jumps'' = (Lambda x jumps(x)) . ``John'' = john.
that argument is substituted for x: jumps(john).
7
(Lambda x .f) is a function with one argument. (Lambda x .f) (v) is equivalent to f, with every occurence of x replaced by
So.. (Lambdax.x +1)(2) =2+1 and (Lambda x.f(x,y))(3)= f(3,y) (Lambda y.f(x,y))(3)= f(x,3) (Lambda x.loves(john,x))(marry)= loves(john,marry) We can also have nested lambda expressions, with the outer most one applied first. (Lambda x.lambda y.f(x,y))(2)= (lambda y. f(2,y)) (Lambda x.lambda y.f(x,y))(2)(3) = f(2,3)
8
9
Let each word in the lexicon have an associated lambda expression as its semantics:
We now associate, with each grammar rule, a rule for combining the semantics of subconstituents.
s(Sem) --> np(NPSem), vp(VPSem), {Apply VPSem to NPSem to get Sem}. np(Sem) --> name(Sem). vp(Sem) --> v(Sem).
Now, to find the semantics of ``John jumps'' we apply (lambda x. jumps(x)) to john to get: (lambda x. jumps(x))(john) = jumps(john)
10
What about ``John loves Mary''? Will the same approach work? Yes, if we make the semantics for ``loves'' a little more complex: ``loves'': (lambda x. lambda y. loves(y,x)) s(Sem) --> np(NPSem), vp(VPSem), {Apply VPSem to NPSem to get Sem}. vp(Sem) --> v(VSem), np(NSem), {Apply VSem to NSem to get Sem} Now semantics for ``loves Mary'' is: (lambda x. lambda y. loves(y,x))(marry) = (lambda y.loves(y,marry) then combining with the semantics for John we get: (lambda y.loves(y,marry))(john) = loves(john, mary)
11
12
Notation: X^ loves(X,Y) ==(Lambda x, loves(x,y)). X^Y^loves(X, Y)==(Lambda x.Lambda y.loves(x,y)). Combining: We want to be able to reduce (Lambda x.loves(x,john))(mary) to get loves(mary, john). So in Prolog we want: ?- reduce(X ^ loves(X, john), mary, Answer). Answer = loves(mary, john).
Exercise: Try writing a reduce predicate to do this!
13
Once we have a ``reduce'' predicate we can rely on pattern matching:
s(Sem) --> np(NSem), vp(VSem), {reduce(VSem, NSem, Sem)}. vp(VP) --> tv(TV), np(NP), {reduce(TV, NP, VP)}. np(NP) --> propn(NP). tv(X^Y^loves(Y, X)) --> [loves]. propn(john) --> [john]. propn(mary) --> [mary]. Analysis of ``John loves Mary'': loves: TV = X^Y^loves(Y, X) Mary: NP = mary. combine to give: vp: VSem = Y^loves(Y,mary) combined with John: NSem = john gives: s: Sem = loves(john, mary).
14
a(art AGR 3s SEM INDEF1) can(aux SUBCAT base SEM CAN1) car(n SEM CAR1 AGR 3s) cry(v SEM CRY1 VFORM base SUBCAT _none) decide(v SEM DECIDE1 VFORM base SUBCAT _none) decide(v SEM DECIDE-ON1 VFORM base SUBCAT _pp:on) dog(n SEM DOG1 AGR 3s) fish(n SEM FISH1 AGR 3s) fish(n SEM (PLUR FISH1) AGR 3p) he(pro SEM HE1 AGR 3s) man(n SEM MAN1 AGR 3s) men(n SEM (PLUR MAN1) AGR 3p) Jill(name AGR 3s SEM “Jill”) ……. ……….
15
16