| Aim: |
|
To describe an interpretation algorithm that uses the syntactic
analysis of a sentence together with grammar rules augmented by
feature information describing how the semantic analysis of a phrase
is derived from the semantic analyses of its constituents. We shall
show how this works for a simple grammar and then investigate a
few more complicated examples, including the handling of auxiliary
verbs, and prepositional phrases. The concepts of lambda-expression and lambda-reduction are central to the handling of certain grammar rules. |
| Reference: Chapter 9 of Allen, J.: Natural Language Understanding, 2nd ed., Benjamin Cummings, 1995. |
| Keywords: CNP, common noun phrase, lambda reduction, VAR feature |
| Plan: |
|
| James Allen, who wrote the textbook we follow in the NLP section of this course, is a professor in Computer Science at the University of Rochester in the USA. Allen is a distinguished researcher in the NLP field, and a former editor-in-chief of the important NLP journal Computational Linguistics. The picture is from his home page, which is linked above. | ![]() James Allen |
kiss1(k1, name(J1, 'Jack'), name(S1, 'Sue'))
is a predicate that takes one argument.
lambda(X, kiss1(k1, X, name(s1, 'Sue'))) (name(j1, 'Jack')) *
kiss1(k1, name(j1, 'Jack'), name(s1, 'Sue'))
lambda(X, at_loc(X, the<s1, store1>)).
at_loc(the<m1, man1> the<s1, store1>).
S(sem(?semvp(?semnp))) → NP(sem(?semnp)) VP(sem(?semvp))
The whole of the parse/semantic tree for this sentence (Mary sees Jack) is shown below (equivalent to Fig. 9.1 of Allen):
| 1 | S(sem(?semvp(?semnp))) → NP(sem(?semnp)) VP(sem(?semvp)) |
| 2 | VP(var(?v), sem(lambda(a2, ?semv(?v, a2)))) → V[_none](sem(?semv)) |
| 3 | VP(var(?v), sem(lambda(a3, ?semv(?v, a3, ?semnp)))) → V[np](sem(?semv)) NP(sem(?semnp)) |
| 4 | NP(wh(-), var(?v), sem(pro(?v, ?sempro))) → PRO(sem(?sempro)) |
| 5 | NP(var(?v), sem(name(?v, ?semname))) → NAME(sem(?semname)) |
| 6 | NP(var(?v), sem(?semdet(?v, ?semcnp(?v)))) → DET(sem(?semdet)) CNP(sem(?semcnp)) |
| 7 | CNP(sem(?semn)) → N(sem(?semn)) |
Head_feature(s, vp, np, cnp) = var
n(agr(3s))
n(agr/3s) works - remember that Prolog doesn't try to
evaluate / unless is
(or an arithmetic comparison operator) is used.
vp(P1, P2, vp(Verb), lambda(X, SemBody), VarV) :-
v(P1, P2, Verb, SemV, VarV),
SemBody =.. [SemV, VarV, X].
=.. (pronounced "univ") converts a list into a term,
and works like this:
?- Term =.. [likes, mary, pizza]. Term = likes(mary, pizza)
vp term:
P1 and P2,
are the start and finish positions of the phrase in the sentence,
as with the Prolog syntax rules that we met earlier.)
vp is filled by noting
that the var of the vp is the same as the
var of the v (var is a head feature
for vp) so we just put VarV in the
var slot in the head of the rule.
vp rule in action - we need some facts. Let's
suppose that v(2, 3, laugh, laugh1, l1) has already been proven
using the rule for v, like the syntax rule for v that we saw earlier,
but enhanced to provide a semantic analysis ( laugh1 ) and a var
feature ( l1 ).
?- vp(P1, P2, Syn, Sem, Var). results in the
bindings:
P1 = 2 P2 = 3 Syn = vp(v(laugh)) Sem = lambda(_G300, laugh1(l1, _G300)) Var = l1
X.
lambda(X, laugh1(l1, X)) says, roughly, that there is an instance
l1 of laughing (strictly speaking, laugh1-ing), and someone
(X) is the agent of this laughing, i.e. is the one who is doing
the laughing.
| a | det(agr(3s), sem(a)) |
| can | aux(subcat(base), sem(can1)) |
| car | n(sem(car1), agr(3s)) |
| cry | v(sem(cry1), vform(base), subcat(none)) |
| decide | v(sem(decides1), vform(base), subcat(none)) |
| decide | v(sem(decides_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)) |
| house | n(sem(house1), agr(3s)) |
| has | aux(vform(pres), agr(3s), subcat(pastprt), sem(perf)) |
| he | pro(sem(he1), agr(3s)) |
| in | p(pform([loc, mot]), sem(at_loc1)) |
| Jill | name(agr(3s), sem('Jill')) |
| man | n(sem(man1), agr(3s)) |
| men | n(sem(plur(man1)), agr(3p)) |
| on | p(pform([loc, on]), sem(on_loc1)) |
| saw | v(sem(sees1), vform(past), subcat(np)) |
| see | v(sem(sees1), vform(base), subcat(np), irreg_past(+), en_pastprt(+)) |
| she | pro(sem(she1), agr(3s)) |
| the | det(sem(the), agr([3s, 3p])) |
| to | to(agr(-), vform(inf)) |
The chart parser can be modified so that it handles semantic interpretation as follows:
Interpreting an example sentence: Jill saw the dog
lambda(X, past(sees1)(ev1, X, the(d1, dog1(d1))))
past(sees1)(ev1, name(j1, 'Jill'), the(d1, dog1(d1)))
and var ev1 (after lambda-reduction).
Completed Parse Tree for Jill saw the dog (Fig. 9.5 Allen)
Auxiliary Verbs
VP(sem(lambda(A1, ?semaux(?semvp(A1))))) →
AUX(subcat(?v), sem(?semaux)) VP(vform(?v), sem(?semvp))
lambda(A1, can1( lambda(X, laughs1(e3, X)) (A1)))
Examples:
| The man | in the corner ate lunch. |
| PP modifies NP the man | |
| The dog barked | in the alley. |
| PP modifies VP barked | |
| She is ready to take | up the challenge. |
| up flags object of "take-up" |
PP(sem(lambda(Y, ?semp(Y, ?semnp))) → P(sem(?semp)) NP(sem(?semnp))
lambda(Y, at_loc1(Y, the<c1, corner1>))
CNP(sem(lambda(N1, &(?semcnp(N1), ?sempp(N1))))) → CNP(sem(?semcnp)) PP(sem(?sempp))
[Here & means "and". It is used here as a prefix operator. Thus &(happy(fido), dog(fido)) would mean "Fido is happy and Fido is a dog". &(man1(x), in_loc1(x, the<c1, corner1>)) means "x is a man and (&) x is in the corner".
cnp(P1, P3, cnp(SynCNP, SynPP),
lambda(N1, &(SemCNPN1, LR_Result)),
VarCNP) :-
SemCNPN1 =.. [SemCNP, N1],
cnp(P1, P2, SynCNP, SemCNP, VarCNP),
pP(P2, P3, SynPP, SemPP, VarPP),
lambda_reduce(SemPP,N1,LR_Result).
where lambda_reduce is defined by:
lambda_reduce(lambda(X, Predicate), Argument, Predicate) :-
X = Argument.
lambda_reduce(Expression, _, Expression) :-
Expression \= lambda(_, _).
lambda(N1, &(man1(N1), (lambda(Y, at_loc1(Y, the<c1, corner1>)) N1)))
lambda(N1, &(man1(N1), at_loc1(N1, the<c1, corner1>)))
the(m2, (lambda(N1, &(man1(N1), at_loc1(N1, the<c1, corner1>))) m2))
which simplifies to
the(m2, &(man1(m2), at_loc1(m2, the<c1, corner1>)))
lambda(A, &(cries1(e1, A), at_loc1(e1, the<c1, corner1>))) and e1
VP(var(?v), sem(lambda(X, &(?semvp(x), ?sempp(?v))))) →
VP(var(?v), sem(?semvp)) PP(sem(?sempp))
[NB: This VP rule will be superseded by two more specific ones soon.]
You are now in a position to do all of the exercises at http://www.cse.unsw.edu.au/~cs9414/Exercises/semantics.html
Parse tree for cry in the corner using this rule: (like Allen Fig. 9.6, corrected):
VP → V[_pp:on] PP[on]
lambda(S, decides_on1(d1, S, a<c1, couch1>))
with a<c1, couch1> appearing as an argument.
| predicate: decide (while sitting) on a couch | = pred + |
| argument: decide on (e.g. to buy) a couch | = pred – |
PP(pred(+), sem(lambda(X, ?semp(X, ?semnp)))) → P(sem(?semp)) NP(sem(?semnp))
- interprets preposition as predicate
PP(pred(–), pform(?pf), sem(?semnp)) → P(root(?pf)) NP(sem(?semnp))
- interprets the NP in the PP as an argument of the verb
VP(var(?v), sem(lambda(X1, &(?semvp(X1), ?sempp(?v))))) →
VP(sem(?semvp)) PP(pred(+), sem(?sempp))
VP(var(?v), sem(lambda(X2, ?semv(?v) X2 ?sempp))) →
V[pp:on](sem(?semvp)) PP(pred(–), pform(on), sem(?sempp))
| Summary: Semantic Interpretation |
| The semantic interpretation algorithm is feature-driven: reading the augmented grammar rules right to left provides a description of how to build the SEM feature of the phrase described by the grammar rule. When the semantic description has a gap (as with VP), the SEM feature is a lambda-expression. |
CRICOS Provider Code No. 00098G
Copyright (C) Bill Wilson, 2009, except where another source is acknowledged.