+ All Categories
Home > Documents > Computational Semantics coli.uni-sb.de/cl/projects/milca/esslli

Computational Semantics coli.uni-sb.de/cl/projects/milca/esslli

Date post: 04-Feb-2016
Category:
Upload: vinson
View: 33 times
Download: 0 times
Share this document with a friend
Description:
Computational Semantics http://www.coli.uni-sb.de/cl/projects/milca/esslli. Aljoscha Burchardt, Alexander Koller, Stephan Walter, Universität des Saarlandes, Saarbrücken, Germany ESSLLI 2004, Nancy, France. Computational Semantics. - PowerPoint PPT Presentation
Popular Tags:
39
Computational Semantics http://www.coli.uni-sb.de/cl/projects/milca/esslli Aljoscha Burchardt, Alexander Koller, Stephan Walter, Universität des Saarlandes, Saarbrücken, Germany ESSLLI 2004, Nancy, France
Transcript
Page 1: Computational Semantics coli.uni-sb.de/cl/projects/milca/esslli

Computational Semanticshttp://www.coli.uni-sb.de/cl/projects/milca/esslli

Aljoscha Burchardt,

Alexander Koller,

Stephan Walter,Universität des Saarlandes,

Saarbrücken, Germany

ESSLLI 2004, Nancy, France

Page 2: Computational Semantics coli.uni-sb.de/cl/projects/milca/esslli

Computational Semantics

• How can we compute the meaning of e.g. an English sentence?– What do we mean by “meaning“?– What format should the result have?

• What can we do with the result?

Page 3: Computational Semantics coli.uni-sb.de/cl/projects/milca/esslli

The Big Picture

• Sentence: “John smokes”.

• Syntactic Analyses: S

NPVP

Johnsmokes

• Semantics Construction: smoke(j)• Inference: x.smoke(x)snore(x),smoke(j)

=> snore(j)

Page 4: Computational Semantics coli.uni-sb.de/cl/projects/milca/esslli

Course Schedule

• Monday - Thursday: Semantics Construction– Mon.+Tue.: Lambda-Calculus– Wed.+Thu.: Underspecification

• Friday: Inference– (Semantic) Tableaux

Page 5: Computational Semantics coli.uni-sb.de/cl/projects/milca/esslli

The Book

• If you want to read more about computational semantics, see the forthcoming book:

Blackburn & Bos, Representation and Inference: A first course in

computational semantics. CSLI Press.

Page 6: Computational Semantics coli.uni-sb.de/cl/projects/milca/esslli

Today (Monday)

• Meaning Representation in FOL

• Basic Semantics Construction-Calculus

• Semantics Construction with Prolog

Page 7: Computational Semantics coli.uni-sb.de/cl/projects/milca/esslli

Meaning Representations

• Meaning representations of NL sentences

• First Order Logic (FOL) as formal language– “John smokes.“

=> smoke(j)

– “Sylvester loves Tweety.” => love(s,t)

– “Sylvester loves every bird.” => x.(bird(x) love(s,x))

Page 8: Computational Semantics coli.uni-sb.de/cl/projects/milca/esslli

In the Background: Model Theory

x.(bird(x) love(s,x)) is a string again!

• Mathematically precise model representation, e.g.: {cat(s), bird(t), love(s,t), granny(g), own(g,s), own(g,t)}

• Inspect formula w.r.t. to the model: Is it true?

• Inferences can extract information: Is anyone not owned by Granny?

Page 9: Computational Semantics coli.uni-sb.de/cl/projects/milca/esslli

FOL Syntax (very briefly)

FOL Formulae, e.g. x.(bird(x) love(s,x))

FOL Language– Vocabulary (constant symbols and

predicate/relation symbols)– Variables– Logical Connectives– Quantifiers– Brackets, dots.

Page 10: Computational Semantics coli.uni-sb.de/cl/projects/milca/esslli

What we have done so far

• Meaning Representation in FOL • Basic Semantics Construction-Calculus

• Semantics Construction with Prolog

Page 11: Computational Semantics coli.uni-sb.de/cl/projects/milca/esslli

Syntactic Analyses

Basis: Context Free Grammar (CFG)Grammar Rules:

S NP VPVP TV NPTV loveNP john Lexical Rules / LexiconNP mary...

Page 12: Computational Semantics coli.uni-sb.de/cl/projects/milca/esslli

Example: Syntactic Analyses

Page 13: Computational Semantics coli.uni-sb.de/cl/projects/milca/esslli

Example: Semantic Lexicon

Page 14: Computational Semantics coli.uni-sb.de/cl/projects/milca/esslli

Example: Semantics Construction

Page 15: Computational Semantics coli.uni-sb.de/cl/projects/milca/esslli

Example: Semantics Construction

Page 16: Computational Semantics coli.uni-sb.de/cl/projects/milca/esslli

Compositionality

The meaning of the sentence is constructed from:– The meaning of the

words: john, mary, love(?,?) (lexicon)

– Paralleling the syntactic construction (“semantic rules”)

Page 17: Computational Semantics coli.uni-sb.de/cl/projects/milca/esslli

Systematicity

• How do we know that e.g. the meaning of the VP “loves Mary” is constructed as love(?,mary) and not as

love(mary,?) ?

• Better: How can we specify in which way the bits and pieces combine?

Page 18: Computational Semantics coli.uni-sb.de/cl/projects/milca/esslli

Systematicity (ctd.)

• Parts of formulae (and terms), e.g. for the VP “love Mary”?– love(?,mary) bad: not FOL– love(x,mary) bad: no control over

free variable

• Familiar well-formed formulae (sentences): x.love(x,mary) “Everyone loves Mary.” x.love(mary,x) “Mary loves someone.”

Page 19: Computational Semantics coli.uni-sb.de/cl/projects/milca/esslli

Using Lambdas (Abstraction)

• Add a new operator to bind free variables:x.love(x,mary) “to love Mary”

• The new meta-logical symbol marks missing information in the object language (-)FOL

• We abstract over x.• How do we combine these new formulae

and terms?

Page 20: Computational Semantics coli.uni-sb.de/cl/projects/milca/esslli

Super Glue

• Glueing together formulae/terms with a special symbol @:

x.love(x,mary) john

x.love(x,mary)@john• Often written as x.love(x,mary)(john)• How do we get back to the familiar

love(john,mary)?

Page 21: Computational Semantics coli.uni-sb.de/cl/projects/milca/esslli

Functional Application

• “Glueing” is known as Functional Application

• FA has the Form: Functor@Argument

x.love(x,mary)@john• FA triggers a very simple operation:

Replace the -bound variable by the argument.

x.love(x,mary)@john

=> love(john,mary)

Page 22: Computational Semantics coli.uni-sb.de/cl/projects/milca/esslli

-Reduction/Conversion

1. Strip off the -prefix,

2. Remove the argument (and the @),

3. Replace all occurences of the -bound variable by the argument.

x.love(x,mary)@john1. love(x,mary)@john

2. love(x,mary)

3. love(john,mary)

Page 23: Computational Semantics coli.uni-sb.de/cl/projects/milca/esslli

Semantics Construction with Lambdas

S: John loves Mary(yx.love(x,y)@mary)@john

TV: lovesyx.love(x,y)

NP: Marymary

NP: Johnjohn

VP: loves Maryyx.love(x,y)@mary

Page 24: Computational Semantics coli.uni-sb.de/cl/projects/milca/esslli

Example: Beta-Reduction

(yx.love(x,y)@mary)@john

=> (x.love(x,mary))@john

=> love(john,mary)

Page 25: Computational Semantics coli.uni-sb.de/cl/projects/milca/esslli

In the Background

-Calculus – A logical standard technique offering more than -

abstraction, functional @pplication and β-reduction.

• Other Logics– Higher Order Logics

– Intensional Logics

• ...• For linguistics: Richard Montague (early seventies)

Page 26: Computational Semantics coli.uni-sb.de/cl/projects/milca/esslli

What we have done so far

• Meaning Representation in FOL • Basic Semantics Construction -Calculus • Semantics Construction with Prolog

Page 27: Computational Semantics coli.uni-sb.de/cl/projects/milca/esslli

Plan

Next, we

• Introduce a Prolog represenation.

• Specify a syntax fragment with DCG.

• Add semantic information to the DCG.

• (Implement β-reduction.)

Page 28: Computational Semantics coli.uni-sb.de/cl/projects/milca/esslli

Prolog Representation: Terms and Formulae

(man(john)&(~(love(mary,john))))

(happy(john)>(happy(mary)v(happy(fido)))

forall(x,happy(x))

exists(y,(man(y)&(~(happy(y))))

lambda(x,…)

Page 29: Computational Semantics coli.uni-sb.de/cl/projects/milca/esslli

Prolog Representation:Operator Definitions

:- op(950,yfx,@). % application

:- op(900,yfx,>). % implication

:- op(850,yfx,v).   % disjunction

:- op(800,yfx,&).   % conjunction

:- op(750, fy,~).    % negation

forall(x,man(x)&~love(x,mary)>hate(mary,x))

(„Mary hates every man that doesn‘t love her.“)

BindingStrength

Page 30: Computational Semantics coli.uni-sb.de/cl/projects/milca/esslli

Definite Clause Grammar

• Prolog‘s built-in grammar formalism• Example grammar:

s --> np,vp.vp --> iv. vp --> tv,np....np --> [john].iv --> [smokes].

• Call: s([john,smokes],[]).

Page 31: Computational Semantics coli.uni-sb.de/cl/projects/milca/esslli

Adding Semantics to DCG

• Adding an argument to each DCG rule to collect semantic information.

• Phrase rules of our first semantic DCG:

s(VP@NP) --> np(NP),vp(VP).

vp(IV) --> iv(IV).

vp(TV@NP) --> tv(TV),np(NP).

Page 32: Computational Semantics coli.uni-sb.de/cl/projects/milca/esslli

Lexicon Of Our First Semantic DCG

np(john) --> [john].

np(mary) --> [mary].

iv(lambda(X,smoke(X))) -->

[smokes],{vars2atoms(X)}.

tv(lambda(X,lambda(Y,love(Y,X)))) -->

[loves],{vars2atoms(X),

vars2atoms(Y)}.

Page 33: Computational Semantics coli.uni-sb.de/cl/projects/milca/esslli

Running Our First Semantics Constrution

?- s(Sem,[mary,smokes],[]).

Sem = lambda(v1, smoke(v1))@mary

?- …, betaConvert(Sem,Result).

Result = smoke(mary)

Note that we use some special predicates of freely available SWI Prolog (http://www.swi-prolog.org/).

Page 34: Computational Semantics coli.uni-sb.de/cl/projects/milca/esslli

betaConvert(Formula,Result) 1/2

betaConvert(Functor@Arg,Result):-betaConvert(Functor,lambda(X,Formula)),!,substitute(Arg,X,Formula,Substituted),betaConvert(Substituted,Result).

1. The input expression is of the form [email protected]. The functor has (recursively) been reduced to

lambda(X,Formula).

Note that the code displayed in the reader is wrong. Corrected pages can be downloaded.

Page 35: Computational Semantics coli.uni-sb.de/cl/projects/milca/esslli

betaConvert(Formula,Result) 2/2

betaConvert(Formula,Result):-compose(Formula,Functor,Formulas),betaConvertList(Formulas,Converted),compose(Result,Functor,Converted).

Formula = exists(x,man(x)&(lambda(z),walk(z)@x))

Functor = existsFormulas = [x,man(x)&(lambda(z),walk(z)@x))]

Converted = [x,man(x)&walk(x)]Result = exists(x,man(x)&walk(x))

Page 36: Computational Semantics coli.uni-sb.de/cl/projects/milca/esslli

Helper Predicates

betaConvertList([],[]).

betaConvertList([F|R],[F_Res|R_Res]):-        betaConvert(F,F_Res),        betaConvertList(R,R_Res).

compose(Term,Symbol,Args):-

Term =.. [Symbol|Args].

substitute(…) (Too much for a slide.)

Page 37: Computational Semantics coli.uni-sb.de/cl/projects/milca/esslli

Wrapping It Up

go :-

resetVars,

readLine(Sentence),

s(Formula,Sentence,[]),

nl, print(Formula),

betaConvert(Formula,Converted),

nl, print(Converted).

Page 38: Computational Semantics coli.uni-sb.de/cl/projects/milca/esslli

Adding More Complex NPs

NP: A man ~> x.man(x)

S: A man loves Mary

Let‘s try it in a system demo!

Page 39: Computational Semantics coli.uni-sb.de/cl/projects/milca/esslli

Tomorrow

S: A man loves Mary

~> * love(x.man(x),mary)• How to fix this.• A DCG for a less trivial fragment of

English.• Real lexicon.• Nice system architecture.


Recommended