lecture parsing
TRANSCRIPT
-
7/31/2019 Lecture Parsing
1/40
PARSING WITHCONTEXT-FREE GRAMMARS
- by FaaDoOEngineers.com
-
7/31/2019 Lecture Parsing
2/40
PARSING
Parsing is the process of recognizing and
assigning STRUCTURE Parsing a string with a CFG:
Finding a derivation of the string consistent withthe grammar
The derivation gives us a PARSE TREE
- by FaaDoOEngineers.com
-
7/31/2019 Lecture Parsing
3/40
EXAMPLE (CFR LAST WEEK)
- by FaaDoOEngineers.com
-
7/31/2019 Lecture Parsing
4/40
-
7/31/2019 Lecture Parsing
5/40
TOP-DOWN AND BOTTOM-UP
SEARCH STRATEGIES
The search has to be guided by the INPUT
and the GRAMMAR TOP-DOWN search: the parse tree has to
be rooted in the start symbol S
EXPECTATION-DRIVEN parsing
BOTTOM-UP search: the parse tree must bean analysis of the input
DATA-DRIVEN parsing
- by FaaDoOEngineers.com
-
7/31/2019 Lecture Parsing
6/40
AN EXAMPLE OF TOP-DOWN SEARCH
(IN PARALLEL)
- by FaaDoOEngineers.com
-
7/31/2019 Lecture Parsing
7/40
AN EXAMPLE OF BOTTOM-UP
SEARCH
- by FaaDoOEngineers.com
-
7/31/2019 Lecture Parsing
8/40
-
7/31/2019 Lecture Parsing
9/40
TOP-DOWN, DEPTH-FIRST,
LEFT-TO-RIGHT
- by FaaDoOEngineers.com
-
7/31/2019 Lecture Parsing
10/40
-
7/31/2019 Lecture Parsing
11/40
TOP-DOWN, DEPTH-FIRST,
LEFT-TO-RIGHT (III)
- by FaaDoOEngineers.com
-
7/31/2019 Lecture Parsing
12/40
TOP-DOWN, DEPTH-FIRST,
LEFT-TO-RIGHT (IV)
- by FaaDoOEngineers.com
-
7/31/2019 Lecture Parsing
13/40
A T-D, D-F, L-R PARSER
- by FaaDoOEngineers.com
-
7/31/2019 Lecture Parsing
14/40
TOP-DOWN vs BOTTOM-UP
TOP-DOWN: Only search among grammatical answers
BUT: suggests hypotheses that may not beconsistent with data
Problem: left-recursion
BOTTOM-UP: Only forms hypotheses consistent with data
BUT: may suggest hypotheses that make nosense globally
- by FaaDoOEngineers.com
-
7/31/2019 Lecture Parsing
15/40
LEFT-RECURSION
A LEFT-RECURSIVE grammar may cause a
T-D, D-F, L-R parser to never return Examples of left-recursive rules:
NP NP PP
S S and S
But also: NP Det Nom
DetNPs
- by FaaDoOEngineers.com
-
7/31/2019 Lecture Parsing
16/40
-
7/31/2019 Lecture Parsing
17/40
LEFT-RECURSION: POOR SOLUTIONS
Rewrite the grammar to a weakly equivalent
one Problem: may not get correct parse tree
Limit the depth during search
Problem: limit is arbitrary
- by FaaDoOEngineers.com
-
7/31/2019 Lecture Parsing
18/40
LEFT-CORNER PARSING
A hybrid of top-down and bottom-up parsing
Strategy: dont consider any expansionunless the current input can serve as theLEFT-CORNER of that expansion
- by FaaDoOEngineers.com
-
7/31/2019 Lecture Parsing
19/40
-
7/31/2019 Lecture Parsing
20/40
COMMON STRUCTURAL AMBIGUITIES
COORDINATION ambiguity
OLD (MEN AND WOMEN) vs(OLD MEN) AND WOMEN
ATTACHMENT ambiguity:
Gerundive VP attachment ambiguity
I saw the Eiffel Tower flying to Paris PP attachment ambiguity
I shot an elephant in my pajamas
- by FaaDoOEngineers.com
-
7/31/2019 Lecture Parsing
21/40
PP ATTACHMENT AMBIGUITY
- by FaaDoOEngineers.com
-
7/31/2019 Lecture Parsing
22/40
-
7/31/2019 Lecture Parsing
23/40
-
7/31/2019 Lecture Parsing
24/40
INVARIANTS AND TOP-DOWN
PARSING
- by FaaDoOEngineers.com
-
7/31/2019 Lecture Parsing
25/40
-
7/31/2019 Lecture Parsing
26/40
DYNAMIC PROGRAMMING
A standard T-D parser would reanalyze AFLIGHT 4 times, always in the same way
A DYNAMIC PROGRAMMING algorithmuses a table (the CHART) to avoid repeatingwork
The Earley algorithm also Does not suffer from the left-recursion problem
Solves an exponential problem in O(n3)
- by FaaDoOEngineers.com
-
7/31/2019 Lecture Parsing
27/40
THE CHART
The Earley algorithm uses a table (the CHART) ofsize N+1, where N is the length of the input
Table entries sit in the `gaps between words
Each entry in the chart is a list of
Completed constituents
In-progress constituents
Predicted constituents
All three types of objects are represented in thesame way as STATES
- by FaaDoOEngineers.com
-
7/31/2019 Lecture Parsing
28/40
THE CHART:
GRAPHICAL REPRESENTATION
- by FaaDoOEngineers.com
-
7/31/2019 Lecture Parsing
29/40
STATES
A state encodes two types of information: How much of a certain rule has been encountered
in the input Which positions are covered
A, [X,Y]
DOTTED RULES VP V NP
NP Det Nominal
S VP
- by FaaDoOEngineers.com
-
7/31/2019 Lecture Parsing
30/40
EXAMPLES
- by FaaDoOEngineers.com
-
7/31/2019 Lecture Parsing
31/40
SUCCESS
The parser has succeeded if entry N+1 of thechart contains the state
S, [0,N]
- by FaaDoOEngineers.com
-
7/31/2019 Lecture Parsing
32/40
-
7/31/2019 Lecture Parsing
33/40
-
7/31/2019 Lecture Parsing
34/40
-
7/31/2019 Lecture Parsing
35/40
-
7/31/2019 Lecture Parsing
36/40
EXAMPLE:
BOOK THAT FLIGHT
- by FaaDoOEngineers.com
-
7/31/2019 Lecture Parsing
37/40
EXAMPLE:
BOOK THAT FLIGHT (II)
- by FaaDoOEngineers.com
-
7/31/2019 Lecture Parsing
38/40
-
7/31/2019 Lecture Parsing
39/40
EXAMPLE:
BOOK THAT FLIGHT (IV)
- by FaaDoOEngineers.com
-
7/31/2019 Lecture Parsing
40/40