chart parsing
DESCRIPTION
Chart Parsing. Allen ’ s Chapter 3 J & M ’ s Chapter 10. Chart Parsing. General Principles: A Bottom-Up parsing method – Construct a parse starting from the input symbols – Build constituents from sub-constituents - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Chart Parsing](https://reader033.vdocuments.us/reader033/viewer/2022042506/56813b72550346895da47d22/html5/thumbnails/1.jpg)
1
Chart Parsing
Allen’s Chapter 3
J & M’s Chapter 10
![Page 2: Chart Parsing](https://reader033.vdocuments.us/reader033/viewer/2022042506/56813b72550346895da47d22/html5/thumbnails/2.jpg)
2
Chart Parsing
General Principles: A Bottom-Up parsing method
– Construct a parse starting from the input symbols– Build constituents from sub-constituents– When all constituents on the RHS of a rule are matched, create a
constituent for the LHS of the rule
The Chart allows storing partial analyses, so that they can be shared.
Data structures used by the algorithm:– The Key: the current constituent we are attempting to “match”– An Active Arc: a grammar rule that has a partially matched RHS– The Agenda: Keeps track of newly found unprocessed constituents– The Chart: Records processed constituents (non-terminals) that span
substrings of the input
![Page 3: Chart Parsing](https://reader033.vdocuments.us/reader033/viewer/2022042506/56813b72550346895da47d22/html5/thumbnails/3.jpg)
3
The Chart Parsing Algorithm
Extending Active Arcs with a Key:- Each Active Arc has the form:
<pi> [A X1…C…Xm] <pj>
- A Key constituent has the form: <pj >C<pk>- When processing the Key <p1>C<p2>, we search the active
arc list for an arc <p0>[A X1…C…Xm]<p1>, and then create a new active arc <p0>[A X1…C… Xm]<p2>
- If the new active arc is a completed rule: <p0>[A X1…C]<p2>, then we add <p0>A<p2> to the Agenda
- After “using” the key to extend all relevant arcs, it is entered into the Chart
![Page 4: Chart Parsing](https://reader033.vdocuments.us/reader033/viewer/2022042506/56813b72550346895da47d22/html5/thumbnails/4.jpg)
4
The Chart Parsing Algorithm
The Main Algorithm: parsing input x = x1…xn
1. i = 02. If Agenda is empty and i < n then set i = i + 1, find all
POS of xi and add them as constituents <pi>C<pi+1> to the Agenda
3. Pick a Key constituent <pj>C< pk > from the Agenda4. For each grammar rule of form A CX1…Xm, add
<pj>[A CX1…Xm]<pj> to the list of active arcs5. Use Key to extend all relevant active arcs6. Add LHS of any completed active arcs into the Agenda7. Insert the Key into the Chart8. If Key is <1>S<n> then Accept the input Else goto (2)
![Page 5: Chart Parsing](https://reader033.vdocuments.us/reader033/viewer/2022042506/56813b72550346895da47d22/html5/thumbnails/5.jpg)
5
Chart Parsing - Example
The Grammar:(1) S NP VP
(2) NP ART ADJ N
(3) NP ART N
(4) NP ADJ N
(5) VP AUX VP
(6) VP V NP
![Page 6: Chart Parsing](https://reader033.vdocuments.us/reader033/viewer/2022042506/56813b72550346895da47d22/html5/thumbnails/6.jpg)
6
Chart Parsing - Example
The input: “x = The large can can hold the water”
POS of Input Words:– the: ART– large: ADJ– can: N, AUX, V– hold: N, V– water: N, V
![Page 7: Chart Parsing](https://reader033.vdocuments.us/reader033/viewer/2022042506/56813b72550346895da47d22/html5/thumbnails/7.jpg)
7
The large can can hold the water
![Page 8: Chart Parsing](https://reader033.vdocuments.us/reader033/viewer/2022042506/56813b72550346895da47d22/html5/thumbnails/8.jpg)
8
The large can can hold the water
![Page 9: Chart Parsing](https://reader033.vdocuments.us/reader033/viewer/2022042506/56813b72550346895da47d22/html5/thumbnails/9.jpg)
9
The large can can hold the water
![Page 10: Chart Parsing](https://reader033.vdocuments.us/reader033/viewer/2022042506/56813b72550346895da47d22/html5/thumbnails/10.jpg)
10
The large can can hold the water
![Page 11: Chart Parsing](https://reader033.vdocuments.us/reader033/viewer/2022042506/56813b72550346895da47d22/html5/thumbnails/11.jpg)
11
The final Chart
![Page 12: Chart Parsing](https://reader033.vdocuments.us/reader033/viewer/2022042506/56813b72550346895da47d22/html5/thumbnails/12.jpg)
12
Improved Chart Parser
Increasing the Efficiency of the Algorithm• Observation: The algorithm creates constituents that cannot “fit” into
a global parse structure. Example: <2>[NP ADJ N]<3>
• These can be eliminated using predictions• Using Top-down predictions:
– For each non-terminal A, define First(A) = the set of all leftmost non-terminals derivable from A
– Compute in advance First(A) for all non-terminals A– When processing the key <pj>C<pk> we look for grammar rules that form
an active arc <pj>[A C X2…Xm]<pj>– Add the active arc only if A is predicted: there already exists an active arc
<pk>[B X1…D…Xm]<pj> such that A First(D)– For pk = 1 (arcs of the form <1>[A C X2…Xm]<1>), add the active arc
only if A First(S)
![Page 13: Chart Parsing](https://reader033.vdocuments.us/reader033/viewer/2022042506/56813b72550346895da47d22/html5/thumbnails/13.jpg)
Improved Chart Parser
13
![Page 14: Chart Parsing](https://reader033.vdocuments.us/reader033/viewer/2022042506/56813b72550346895da47d22/html5/thumbnails/14.jpg)
14
Improved Chart Parser - Example
![Page 15: Chart Parsing](https://reader033.vdocuments.us/reader033/viewer/2022042506/56813b72550346895da47d22/html5/thumbnails/15.jpg)
15
The large can can hold the water
![Page 16: Chart Parsing](https://reader033.vdocuments.us/reader033/viewer/2022042506/56813b72550346895da47d22/html5/thumbnails/16.jpg)
16
The large can can hold the water
![Page 17: Chart Parsing](https://reader033.vdocuments.us/reader033/viewer/2022042506/56813b72550346895da47d22/html5/thumbnails/17.jpg)
17