Docsity

Computing Phrase Structure - Introduction to Formal Semantics - Lecture Slides, Slides of Formal Semantics

Toggle sidebar
bg1
Last Time
•Compositionality: meaning of a sentence is composed from
the meaning of its subparts
•example:
– given “John likes Mary” corresponds to likes(john,mary).
– meaning fragments are
•word or phrase meaning
• John john
• likes Mary likes(X,mary).
• likes likes(X,Y).
• Mary mary
– each word here has a contribution to make to the meaning of the
complete sentence
– cf. it is raining (pleonastic “it”/ambient “it”)
sentence
np
np
vp
v
John
Mary
likes
marylikes(X,Y)
likes(X,mary)john
likes(john,mary)
docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16

Partial preview of the text

Download Computing Phrase Structure - Introduction to Formal Semantics - Lecture Slides and more Slides Formal Semantics in PDF only on Docsity!

Last Time

-^ Compositionality

: meaning of a sentence is composed from

the meaning of its subparts• example

-^ given “John likes Mary” corresponds to likes(john,mary).–^ meaning fragments are•

word or phrase

meaning

-^ John

john

-^ likes Mary

likes(X,mary).

-^ likes

likes(X,Y).

-^ Mary

mary

-^ each word here has a contribution to make to the meaning of thecomplete sentence–^ cf. it is raining

(pleonastic “it”/ambient “it”)

sentencenp

vp np v John

Mary likes

mary likes(X,mary)likes(X,Y) likes(john,mary)john

Last Time

-^ Language violates compositionality in the case of idioms •^ example

-^ John kicked the bucket–^ literal meaning

:

-^ word

meaning

-^ john

john

-^ kick

kick(X,Y).

-^ bucket

bucket

-^ idiomatic meaning

:

-^ word

meaning

-^ john

john

-^ kick

-^ bucket

-^ kick the bucket

die(X).

humanities.byu.edu/.../ kick_the_bucket.htmlcf. “kick a bucket”

sentencenp

vp np v John

bucket kicked^

the

Today

•^ look in some detail at what we started last time...• Basic DCG:^ sentence

-->^ np,

vp. vp^ -->

v,^ np. v^ -->^

[likes]. np^ -->

[john]. np^ -->

[mary].

-^ Query

:^ (we supply two arguments:

sentence as a list and an empty list)^ ?-^ sentence([john,likes,mary],[]).Yes^ (Answer)

-^ Meaning DCG:^ –

sentence(P)

-->^ np(NP1),

vp(P),

{saturate1(P,NP1)}.– vp(P)^

-->^ v(P),

np(NP2),

{saturate2(P,NP2)}.

-^ v(likes(X,Y))

-->^ [likes].

-^ np(john)

-->^ [john].

-^ np(mary)

-->^ [mary].

-^ saturate1(P,A)

:-^ arg(1,P,A).

-^ saturate2(P,A)

:-^ arg(2,P,A).

-^ Query

:^ (supply one more argument)

-^ ?- sentence(M,[john,likes,mary],[]). M^ =^ likes(john,mary)

How to turn a basic DCGinto one that “returns” themeaning of a sentence

Part 1

• Computing Phrase Structure

Modify DCG to include Phrase Structure• Basic DCG:^ sentence

-->^ np,

vp. vp^ -->

v,^ np. v^ -->^

[likes]. np^ -->

[john]. np^ -->

[mary].

-^ Procedure:^ –

for each DCG rule, addone argument thatencodes the equivalenttree fragment

-^ DCG rules:^ np

-->^ [john].np -->^ [mary].

-^ add one argument:^ np(

)^ -->

[john]. np(^ )^

-->^ [mary].

-^ substitute tree fragment:^ np(np(john))

-->^ [john]. np(np(mary))

-->^ [mary].

sentencenp John^

vp np v

Mary likes

Prolog

Tree

john^

john mary^

mary likes

likes np(john)np(mary)

np Mary

v likes

np John

Prolog

Tree

v(likes)vp(v(likes),np(mary))

vp^ np v

Mary likes

sentence(np(john),vp(v(likes),np(mary)))

Modify DCG to include Phrase Structure• Basic DCG:^ sentence

-->^ np,

vp. vp^ -->

v,^ np. v^ -->^

[likes]. np^ -->

[john]. np^ -->

[mary].

-^ Procedure:^ –

for each DCG rule, addone argument thatencodes the equivalenttree fragment

-^ DCG rule:^ v

-->^ [likes].

-^ add one argument:^ v(

)^ -->

[likes].

-^ substitute tree fragment:^ v(v(likes))

-->^ [likes].

sentencenp John^

vp np v

Mary likes

Prolog

Tree

john^

john mary^

mary likes

likes np(john)np(mary)

np Mary

v likes

np John

Prolog

Tree

v(likes)vp(v(likes),np(mary))

vp^ np v

Mary likes

sentence(np(john),vp(v(likes),np(mary)))

Modify DCG to include Phrase Structure• DCG rule:^ sentence --> np, vp. • add one argument:^ sentence( ) --> np, vp.^ what goes in there

-^ well, we already havetransformed vp and np totake one argument:^ vp(vp(X,Y)) --> v(X), np(Y).np(np(john)) --> [john].np(np(mary)) --> [mary]. •^ so we have:^ sentence( ) --> np(X),vp(Y). •^ finally:^ sentence(sentence(X,Y)) -->

np(X), vp(Y).

sentencenp John^

vp np v

Mary likes

Prolog

Tree

john^

john mary^

mary likes

likes np(john)np(mary)

np Mary

v likes

np John

Prolog

Tree

v(likes)vp(v(likes),np(mary))

vp^ np v

Mary likes

sentence(np(john),vp(v(likes),np(mary)))

Modify DCG to include Phrase Structure• modification to include one extra argument for each DCG rule is nowcomplete

-^ Basic DCG:^ sentence

-->^ np,

vp. vp^ -->

v,^ np. v^ -->^

[likes]. np^ -->

[john]. np^ -->

[mary].

-^ Query

:^ (we supply two arguments:

sentence as a list and an empty list)^ ?-^ sentence([john,likes,mary],[]).Yes^ (Answer)

-^ Phrase Structure DCG:^ sentence(sentence(NP,VP))

-->^ np(NP),

vp(VP).

vp(vp(V,NP))

-->^ v(V),

np(NP).

v(v(likes))

-->^ [likes]. np(np(john))

-->^ [john]. np(np(mary))

-->^ [mary].

-^ Modified Query

:^ (supply one more argument)

-^ ?- sentence(

PS ,[john,likes,mary],[]). PS^ =^ sentence(np(john),vp(v(likes),np(mary)))

Representing Meaning in Prolog

-^ We don’t need to represent trees here, but we still need to know theequivalences ...•^ example

-^ John likes Mary –^ likes(john,mary)

Equivalences:Meaning

Word/Phrase

john^

John

mary^

Mary

likes(X,Y)

likes

likes(X,mary)

likes Mary likes(X,john)

likes John likes(john,mary)

John likes Mary

sentencenp

vp np v John

Mary likes

mary likes(X,mary)likes(X,Y) likes(john,mary)john

Modify DCG to include Meaning

-^ Basic DCG:^ sentence

-->^ np,

vp. vp^ -->

v,^ np. v^ -->^

[likes]. np^ -->

[john]. np^ -->

[mary].

-^ Procedure:^ –

for each DCG rule, add oneargument that encodes theequivalent meaning fragment

-^ DCG rules:^ np

-->^ [john].np -->^ [mary].

-^ add one argument:^ np(

)^ -->

[john]. np(^ )^

-->^ [mary].

-^ substitute meaning fragment:^ np(john)

-->^ [john]. np(mary)

-->^ [mary].

Equivalences:Meaning

Word/Phrase

john^

John

mary^

Mary

likes(X,Y)

likes

likes(X,mary)

likes Mary likes(X,john)

likes John likes(john,mary)

John likes Mary sentencenp

vp np v John

Mary likes

mary likes(X,mary)likes(X,Y) likes(john,mary)john

Modify DCG to include Meaning

-^ DCG rule:^ vp

-->^ v,

np.

-^ we already have transformed vand np to take one meaningargument:^ v(likes(X,Y))

-->^ [likes]. np(john)

-->^ [john]. np(mary)

-->^ [mary].

-^ so we have:^ vp(

)^ -->

v(Vm),

np(NPm). variables Vm^ =^ “verb meaning”,

NPm^ =

“NP meaning”

-^ we need to encode the notionof argument saturation:^ e.g.

Vm =^

likes(X,Y) NPm =^ mary we^ want the “VP meaning” to be

likes(X,mary) i.e. argument

Y^ gets saturated

Equivalences:Meaning

Word/Phrase

john^

John

mary^

Mary

likes(X,Y)

likes

likes(X,mary)

likes Mary likes(X,john)

likes John likes(john,mary)

John likes Mary sentencenp

vp np v John

Mary likes

mary likes(X,mary)likes(X,Y) likes(john,mary)john

Argument Saturation

•^ we’re gonna need the Prolog built-in arg/3:^ –

arg(Nth,Predicate,Argument) – means make

Nth^ argument of

Predicate

equal to

Argument

•^ example:^ –

given predicate

p(a,b,c)

-^ then –^ ?- arg(1,p(a,b,c),X).

X=a

-^ ?- arg(2,p(a,b,c),X).

X=b

-^ ?- arg(3,p(a,b,c),X).

X=c

-^ ?- arg(4,p(a,b,c),X).

No

•^ example:^ –

given predicate

likes(john,mary)

-^ then –^ ?- arg(1,likes(john,mary),X).

X=john

-^ ?- arg(2,likes(john,mary),X).

X=mary

Modify DCG to include Meaning

-^ we need to encode the notion of argumentsaturation:^ e.g.

Vm =^

likes(X,Y) NPm =^ mary VP meaning must be

Vm

but with

arg(2,Vm,NPm)

being true

-^ we then have:^ vp(Vm) --> v(Vm), np(NPm), {arg(2,VBm,NPm)}. •^ New notation: “

curly braces

•^ {^

}^ means call Prolog

-^ {arg(2,VBm,NPm)}

means call

arg(2,VBm,NPm)

sentencenp

vp np v John

Mary likes

mary likes(X,mary)likes(X,Y) likes(john,mary)john

arg(Nth,Predicate,Argument) means make

Nth^ argument of Predicate

equal to

Argument

-^ perhaps more clearly, we can re-write our DCG rule as:^ vp(Vm) --> v(Vm), np(NPm), {saturate2(Vm,NPm)}. •^ and define the rule (in the Prolog database):^ saturate2(P,A)

:-^ arg(2,P,A).

Modify DCG to include Meaning

-^ finally:^ sentence --> np, vp. •^ we already have transformed vp and np to takeone meaning argument:^ vp(Vm)

-->^ v(Vm),

np(NPm),

{saturate2(Vm,NPm)}.

np(john)

-->^ [john]. np(mary)

-->^ [mary].

-^ we need to encode the notion of argumentsaturation:^ e.g.

Vm =^

likes(X,mary) NPm =^ john we^ want the “sentence meaning” to be

likes(john,mary) i.e. 1st argument

X^ gets

saturated

-^ we then have:^ sentence(VPm) -->

np(NPm), vp(VPm), {arg(1,VPm,NPm)}.

sentencenp

vp np v John

Mary likes

mary likes(X,mary)likes(X,Y) likes(john,mary)john

arg(Nth,Predicate,Argument) means make

Nth^ argument of Predicate

equal to

Argument

{^

}^ means call Prolog

{arg(2,VBm,NPm)}

means

call^ arg(2,VBm,NPm)