Linking Syntax and Semantics Introduction Semantics Interpretation - - PowerPoint PPT Presentation

linking syntax and semantics
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1
  • Ch. 9 Linking Syntax and Semantics

1

Linking Syntax and Semantics

  • Introduction
  • Semantics Interpretation and

Compositionality

  • A Simple Grammar with Semantic

Interpretation

slide-2
SLIDE 2
  • Ch. 9 Linking Syntax and Semantics

2

Introduction

  • Semantic analysis follows syntactic analysis, in trying to

determine what a sentence means.

  • Aim is to use:
  • representations of what individual words mean
  • representation of structure of the sentence (parse tree)

and obtain a representation of the sentence meaning.

  • Ignores context and world knowledge
  • meaning representation may still leave some things

unspecified. (e.g., ``He loves Mary'' - who is ``He'').

slide-3
SLIDE 3
  • Ch. 9 Linking Syntax and Semantics

3

Representing Sentence Meaning

  • Many formalisms have been proposed to represent the

meaning of a sentence.

  • Most common is to use a logic. Predicate logic is a good

place to start.

  • But.. predicate logic not powerful enough to represent all

NL sentences (at least not in simple way).

  • So on the one hand more complex logics have been

suggested.

  • And on the other hand more informal notations have been

used (e.g., case frames).

slide-4
SLIDE 4
  • Ch. 9 Linking Syntax and Semantics

4

Semantic Interpretation and Compositionality

  • Determining the meaning of a sentence will be much

simpler if we can find the meaning of a constituent solely from the meanings of its sub constituents in the parse tree.

  • e.g., Find meaning of sentence by combining meaning
  • f noun phrase with meaning of verb phrase.
  • Rule for combining meanings should be independent of

how noun phrase or verb phrase meanings were found.

  • This is referred to as compositional semantics.
  • But.. developing a good compositional model is very

difficult.

slide-5
SLIDE 5
  • Ch. 9 Linking Syntax and Semantics

5

Why Compositional Semantics is Hard

  • Syntactic structure doesn't always map in any nice way onto semantic

structure: – e.g., syntax: s vp np np name v art n John (loves (every dog))

  • Semantics (LF):

Every d: (DOG1 d) (LOVES1 I1 (NAME j1 “John”) d))

  • Un-scoped version is

(LOVES1 I1 (NAME j1 “John”)<EVERY d DOG1>)

  • Presence of idioms e.g Jack kicked the bucket, which means Jack died.
slide-6
SLIDE 6
  • Ch. 9 Linking Syntax and Semantics

6

Compositional Semantics: A first Attempt

  • Consider ``John jumps'', with semantics jumps(john).
  • How do we give a ``semantics'' to each word (``john'' and ``jumps'') so

they may be combined to give the expression above?

  • A simple answer: Represent the semantics using lambda expressions

e.g., ``jumps'' = (Lambda x jumps(x)) . ``John'' = john.

  • The semantics for jump is now a function with one argument.
  • When this function is applied to an argument (e.g., john, the value of

that argument is substituted for x: jumps(john).

slide-7
SLIDE 7
  • Ch. 9 Linking Syntax and Semantics

7

Lambda Calculus

(Lambda x .f) is a function with one argument. (Lambda x .f) (v) is equivalent to f, with every occurence of x replaced by

  • v. This is known as lambda reduction.

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)

slide-8
SLIDE 8
  • Ch. 9 Linking Syntax and Semantics

8

Combining Syntax and Semantics

Two ways to combine syntactic and semantic analysis.

  • 1. Parse sentence first. Then use parse tree to guide how

semantics of words should be combined.

  • 2. Do both at same time. Work out semantics of

constituents while parsing sentences.

slide-9
SLIDE 9
  • Ch. 9 Linking Syntax and Semantics

9

Compositional Semantics Using Lambda Calculus

Let each word in the lexicon have an associated lambda expression as its semantics:

  • ``jumps'': (lambda x. jumps(x))
  • ``Mary'': mary
  • ``John'': john

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)

slide-10
SLIDE 10
  • Ch. 9 Linking Syntax and Semantics

10

A More Complex Example

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)

slide-11
SLIDE 11
  • Ch. 9 Linking Syntax and Semantics

11

Example Parse Tree with Semantics

slide-12
SLIDE 12
  • Ch. 9 Linking Syntax and Semantics

12

Doing it all in Prolog

  • To do it in Prolog we need a notation for lambda expressions, and a way
  • f combining them (lambda reduction).

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!

slide-13
SLIDE 13
  • Ch. 9 Linking Syntax and Semantics

13

A First Grammar with Semantics in Prolog

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).

slide-14
SLIDE 14
  • Ch. 9 Linking Syntax and Semantics

14

A Small Lexicon

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”) ……. ……….

slide-15
SLIDE 15
  • Ch. 9 Linking Syntax and Semantics

15

Morphological Rules with Semantic Interpretation

(V VFORM pres AGR 3s SEM <PRES ?semv) (V VFORM base IRREG-PRES - SEM ?semv) + S (V VFORM ing SEM ?semv) (V VFORM base SEM ?semv) + ING (V VFORM pastprt SEM ?semv) (V VFORM base EN-PASTPRT + SEM ?semv) + EN (N AGR 3p SEM(PLUR ?sem)) (N AGR 3s IRREG-PL – SEM ?semv)

slide-16
SLIDE 16
  • Ch. 9 Linking Syntax and Semantics

16

Summary

  • Semantic analysis will be much easier if we can find a way

to compose the semantics of sub-constituents to get the semantics of a constituent.

  • Hence ultimately composing the semantics of words, given

the structure of a sentence, to give the semantics of a sentence.

  • One way to do this is to use lambda calculus as the

language for semantics of words.

  • Example: combining , john, and mary, to give loves(john,

mary).