/
LING 388: Language and Computers LING 388: Language and Computers

LING 388: Language and Computers - PowerPoint Presentation

cheryl-pisano
cheryl-pisano . @cheryl-pisano
Follow
391 views
Uploaded On 2016-05-24

LING 388: Language and Computers - PPT Presentation

Sandiway Fong Lecture 13 Adminstrivia Did you attempt Homework 5 yet centerembedded NPs S Recap Original grammar left recursive not Prologsafe VP gt Verb NP VP gt VP PP ID: 332222

limp telescope money boy telescope limp boy money parses recursive formula number total pps case general list attachment safe prolog left grammar

Share:

Link:

Embed:

Download Presentation from below link

Download Presentation The PPT/PDF document "LING 388: Language and Computers" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

Slide1

LING 388: Language and Computers

Sandiway

Fong

Lecture 13Slide2

Adminstrivia

Did you attempt Homework 5 yet?

center-embedded NPs (S)Slide3

Recap

Original grammar (left recursive):

not Prolog-safe

!

VP -> Verb, NP

VP -> VP, PP

Right recursive implementation:

Prolog

-safe

!

produces left recursive trees

(

you can't tell

it's done

right

recursively

)

v2(V,X) --> pp(PP), v2(V,vp(X,PP)).

v2(vp(X,PP),X) --> pp(PP).

vp(X) --> verb(V), np(NP), v2(X,vp(V,NP)).

vp(vp(V,X)) --> verb(V), np(X).Slide4

Recap

Original grammar (left recursive):

not Prolog-safe

!

NP->

Det

, NN

NP-> NP, PP

Right recursive implementation:

Prolog

-safe

!

produces left recursive trees

(

you can't tell it's done right recursively

)

np

(

np

(D,NN)) --> det(D),

nn

(NN).

np

(X) --> det(D),

nn

(NN), v(

X,np

(D,NN)).

v(V,X) -->

pp

(PP), v(

V,np

(X,PP)).

v(

np

(X,PP),X) -->

pp

(PP).Slide5

Recap

From the course

webpage

:

grammar_transformed2

.

plSlide6

PP attachment complexity

Example:

I saw a boy with a telescope with a limp with no money

Stanford Parser:

Next Question:

3

PPs

with a telescope

with

a

limp

with no money

How many parses should we expect?

What's the Stanford parser's

interpretation for PP attachment

here?Slide7

PP attachment complexity

Example:

I saw a boy with a telescope with a limp with no money

How many parses should we expect?

Let's

modify

grammar_transformed2.

pl

to check this …Slide8

saw

a boy

a telescope

a limp

no moneySlide9

saw

a boy

a telescope

a limp

no moneySlide10

saw

a boy

a telescope

a limp

no moneySlide11

saw

a boy

a telescope

a limp

no moneySlide12

saw

a boy

a telescope

a limp

no moneySlide13

s

aw

a

telescope

a limp

no

money

a boySlide14

s

aw

a

telescope

a limp

no money

a boySlide15

s

aw

a

telescope

a

limp

no

money

a boySlide16

s

aw

a

telescope

a

limp

no money

a boySlide17

s

aw

a

telescope

a

limp

no money

a boySlide18

s

aw

no money

a boy

a

telescope

a

limpSlide19

s

aw

a limp

no money

a boy

a telescopeSlide20

s

aw

a limp

no money

a boy

a telescopeSlide21

s

aw

no money

a boy

a telescope

a limpSlide22

Why 14 parses?

Parses for:

I saw a boy with a telescope with a limp with no money

Two attachment points VP (

saw a boy

) and NP (

a boy

) for the three PPs (1.

with a telescope

, 2.

with a limp

, 3.

with no money

)

Four cases:

1. NP (1,2,3) VP2. NP (1,2) VP (3)3. NP (1) VP (2,3)4. NP VP (1,2,3)Two items to attach: two possibilities

X

P 1 XP 1

2 2

Three items to attach: five possibilities

X

P 1 XP 1

XP

1 XP 1 XP 1

2 2 2 2 2

3 3 3 3 3

Total number of parses: 5 + 2 + 2 + 5 = 14Slide23

General recursive formula for # parses

Let

d

k

= configuration at depth

k

(

k

is depth of last PP)

Formula

:

d

k

 d

1 + ..+ dk + dk+1 (k=1,2,3,…)Start:d

1

(case:

one PP, only one place to attach it

)

d

1

+

d

2

(d

1

+

d

2

) + (

d

1

+

d

2

+ d

3

) =

2

d

1

+ 2

d

2

+ 1

d

3

2 (d

1

+

d

2

)

+ 2 (

d

1+ d2 + d

3 ) + (d1+ d

2 + d3 + d4 ) = 5

d1+ 5 d

2 + 3 d3 + 1

d4

Total for one PP: 1

Total for two PPs: 2

Total for 3 PPs: 5

Total for 4 PPs: 14

XP 1 XP 1

XP

1

2 2 2

3 3 3

Depth

:

1

1 2Slide24

General recursive formula for # parses

In principle, the formula allows to extrapolate the number of syntactically valid parses to an arbitrary number of PPs in a row…

perhaps of academic interest only…Slide25

General recursive formula for # parses

Use the formula in conjunction with the possible attachments at the top level:

Case: just one PP phrase, e.g. [

PP1

with a telescope

]

NP (1) VP 1 d

1

NP VP (1) 1 d

1

= 2 (total)

Case: two PP phrases, e.g.

[

PP1

with a telescope

]

[

PP2

with a limp

]

NP (1,2) VP

d

1

+

d

2

NP (1) VP (2) 1 d

1

x 1 d

1

NP

VP

(1,2

)

d

1

+

d

2

= 5 (total)Slide26

General recursive formula for # parses

Case:

three PP

phrases, e.g. [

PP1

with

a telescope

] [

PP2

with a limp

]

[

PP3

with no money

]NP (1,2,3) VP 2 d1+ 2 d2 + d3 NP (1,2) VP (3) (d

1

+

d

2

)

x

1 d

1

NP (

1)

VP

(2,3

) 1 d

1

x

(

d

1

+

d

2

)

NP

VP (

1,2,3)

2 d

1

+ 2 d

2

+

d

3

= 14

(total)Slide27

General recursive formula for # parses

Let’s see if our formula correctly predicts the number of parses for four PPs:

Case: three PP phrases, e.g. [

PP1

with

a telescope

] [

PP2

with

a limp

] [

PP3

with

no money] ] [PP4 with a smile]NP (1,2,3,4) VP 5 d1+ 5 d2 + 3 d3 + d

4

NP

(

1,2,3)

VP

(4)

(

2 d

1

+ 2 d

2

+

d

3

)

x 1 d

1

NP (

1,2)

VP

(3,4)

(

d

1

+

d

2

)

x (

d

1

+

d

2

)

NP (

1)

VP

(2,3,4

) 1 d1 x (2 d1+ 2 d2

+ d3 ) NP VP (

1,2,3,4) 5 d1+ 5 d2

+ 3 d3 + d4

= 42 (total)Slide28

Counting Parses

To count the number of parses, run the command:

f

indall

(

Parse,

sentence

(

Parse,[i,saw,a,boy,with,a,telescope,with,a,limp,with,no,money,with,a,smile],[]),List),

length

(

List,Number

).

Note

:

findall/3 finds all solutions to the s/3

query, each time it finds a solution it puts it into a list (called

List

here)

length/2

: we

evaluate the length of that

List

=

NumberSlide29

Counting ParsesSlide30

Counting ParsesSlide31

Counting Parses

Number of parses increases exponentially..Slide32

Catalan Numbers

See:

http

://en.wikipedia.org/wiki/

Catalan_number