[Back]

Computer Parsing with a CFG


[ Up to Computer Parsing with a CFG]

What is parsing?


QUIZ...

[ Up to What is parsing?]

Example: a simple CFG which accounts for a 'corpus' of three sentences.


[ Up to Example: a simple CFG which accounts for a 'corpus' of three sentences.]

Our 'corpus':


[ Up to Our 'corpus':]

John went to the store.

QUIZ...

[ Up to Our 'corpus':]

He bought some green beens.


[ Up to Our 'corpus':]

Mary thought they were expensive.


[ Up to Example: a simple CFG which accounts for a 'corpus' of three sentences.]

We can cover this 'corpus' completely with the following CFG:

QUIZ...

[ Up to Computer Parsing with a CFG]

Top-down parsing

QUIZ...

[ Up to Top-down parsing]

A trivial example: 'Wow.'

QUIZ...

[ Up to A trivial example: 'Wow.']

We can parse 'Wow.' top-down with a machine thus:


[ Up to We can parse 'Wow.' top-down with a machine thus:]

Start with an 'S' rule.

QUIZ...

[ Up to We can parse 'Wow.' top-down with a machine thus:]

Keep pushing rules that match the RHS of the item on top of the stack until you hit a word in your sentence.

QUIZ...

[ Up to We can parse 'Wow.' top-down with a machine thus:]

When you've found a match, keep the entry in a table (marked in red in the illustration) and pop.

QUIZ...

[ Up to We can parse 'Wow.' top-down with a machine thus:]

The resulting links between successful table entries gives you your tree.

QUIZ...

[ Up to We can parse 'Wow.' top-down with a machine thus:]

What to do when you don't find a match.
QUIZ...

[ Up to Top-down parsing]

A less trivial example: 'Jesus wept.'


QUIZ...

[ Up to Computer Parsing with a CFG]

Bottom-up parsing

QUIZ...

[ Up to Bottom-up parsing]

'Wow.', revisited.


QUIZ...

[ Up to Bottom-up parsing]

'Jesus wept.', revisited.


QUIZ...

[ Up to Computer Parsing with a CFG]

Remarks

QUIZ...