Data classes and parser implementations for "chart parsers", which use dynamic programming to efficiently parse a text. A chart parser derives parse trees for a text by iteratively adding "edges" to a "chart." Each edge represents a hypothesis about the tree structure for a subsequence of the text. The chart is a "blackboard" for composing and combining these hypotheses.
When a chart parser begins parsing a text, it creates a new (empty) chart, spanning the text. It then incrementally adds new edges to the chart. A set of "chart rules" specifies the conditions under which new edges should be added to the chart. Once the chart reaches a stage where none of the chart rules adds any new edges, parsing is complete.
Charts are encoded with the Chart class, and edges are encoded with the TreeEdge and LeafEdge classes. The chart parser module defines three chart parsers:
- ChartParser is a simple and flexible chart parser. Given a set of chart rules, it will apply those rules to the chart until no more edges are added.
- SteppingChartParser is a subclass of ChartParser that can be used to step through the parsing process.
Class |
|
An abstract base class for chart rules. AbstractChartRule provides: |
Class |
|
A ChartParser using a bottom-up parsing strategy. See ChartParser for more information. |
Class |
|
A ChartParser using a bottom-up left-corner parsing strategy. This strategy is often more efficient than standard bottom-up. See ChartParser for more information. |
Class |
|
A rule licensing any edge corresponding to a production whose right-hand side begins with a complete edge's left-hand side. In particular, this rule specifies that [A -> alpha \*] licenses the edge [B -> A \* beta]... |
Class |
|
A rule licensing any edge corresponding to a production whose right-hand side begins with a complete edge's left-hand side. In particular, this rule specifies that [A -> alpha \*] licenses the edge [B -> \* A beta]... |
Class |
|
A cached version of TopDownPredictRule. After the first time this rule is applied to an edge with a given end and next, it will not generate any more edges for edges with that end and next. |
Class |
|
A blackboard for hypotheses about the syntactic constituents of a sentence. A chart contains a set of edges, and each edge encodes a single hypothesis about the structure of some portion of the sentence. |
Class |
|
A generic chart parser. A "strategy", or list of ChartRuleI instances, is used to decide what edges to add to the chart. In particular, ChartParser uses the following algorithm to parse texts: |
Class |
|
A rule that specifies what new edges are licensed by any given set of existing edges. Each chart rule expects a fixed number of edges, as indicated by the class variable NUM_EDGES. In particular: |
Class |
|
A hypothesis about the structure of part of a sentence. Each edge records the fact that a structure is (partially) consistent with the sentence. An edge contains: |
Class |
|
A rule that inserts all empty productions as passive edges, in every position in the chart. |
Class |
|
Undocumented |
Class |
|
Undocumented |
Class |
|
A rule that joins two adjacent edges to form a single combined edge. In particular, this rule specifies that any pair of edges |
Class |
|
An edge that records the fact that a leaf value is consistent with a word in the sentence. A leaf edge consists of: |
Class |
|
Undocumented |
Class |
|
Undocumented |
Class |
|
A rule that joins a given edge with adjacent edges in the chart, to form combined edges. In particular, this rule specifies that either of the edges: |
Class |
|
A ChartParser that allows you to step through the parsing process, adding a single edge at a time. It also allows you to change the parser's strategy or grammar midway through parsing a text. |
Class |
|
A ChartParser using a top-down parsing strategy. See ChartParser for more information. |
Class |
|
A rule licensing edges corresponding to the grammar productions for the grammar's start symbol. In particular, this rule specifies that [S -> \* alpha][0:i] is licensed for each grammar production S -> alpha... |
Class |
|
A rule licensing edges corresponding to the grammar productions for the nonterminal following an incomplete edge's dot. In particular, this rule specifies that [A -> alpha \* B beta][i:j] licenses the edge ... |
Class |
|
An edge that records the fact that a tree is (partially) consistent with the sentence. A tree edge consists of: |
Function | demo |
A demonstration of the chart parsers. |
Function | demo |
Undocumented |
Constant | BU |
Undocumented |
Constant | BU |
Undocumented |
Constant | LC |
Undocumented |
Constant | TD |
Undocumented |
Function | _bottomup |
Undocumented |
A demonstration of the chart parsers.
Undocumented
Value |
|
Undocumented
Value |
|
Undocumented
Value |
|
Undocumented
Value |
|