class InsideChartParser(BottomUpProbabilisticChartParser): (source)
Constructor: InsideChartParser(grammar, beam_size, trace)
A bottom-up parser for PCFG grammars that tries edges in descending order of the inside probabilities of their trees. The "inside probability" of a tree is simply the probability of the entire tree, ignoring its context. In particular, the inside probability of a tree generated by production p with children c[1], c[2], ..., c[n] is P(p)P(c[1])P(c[2])...P(c[n]); and the inside probability of a token is 1 if it is present in the text, and 0 if it is absent.
This sorting order results in a type of lowest-cost-first search strategy.
Method | sort |
Sort the given queue of edges, in descending order of the inside probabilities of the edges' trees. |
Inherited from BottomUpProbabilisticChartParser
:
Method | __init__ |
Create a new BottomUpProbabilisticChartParser, that uses grammar to parse texts. |
Method | grammar |
No summary |
Method | parse |
When possible this list is sorted from most likely to least likely. |
Method | trace |
Set the level of tracing output that should be generated when parsing a text. |
Instance Variable | beam |
Undocumented |
Method | _prune |
Discard items in the queue if the queue is longer than the beam. |
Method | _setprob |
Undocumented |
Instance Variable | _grammar |
The grammar used to parse sentences. |
Instance Variable | _trace |
The level of tracing output that should be generated when parsing a text. |
Inherited from ParserI
(via BottomUpProbabilisticChartParser
):
Method | parse |
No summary |
Method | parse |
No summary |
Method | parse |
Apply self.parse() to each element of sents. :rtype: iter(iter(Tree)) |
Sort the given queue of edges, in descending order of the inside probabilities of the edges' trees.
Parameters | |
queue:list(Edge) | The queue of Edge objects to sort. Each edge in this queue is an edge that could be added to the chart by the fundamental rule; but that has not yet been added. |
chart:Chart | The chart being used to parse the text. This chart can be used to provide extra information for sorting the queue. |
Returns | |
None | Undocumented |