Package nltk :: Package parse :: Module earleychart
[hide private]
[frames] | no frames]

Module earleychart

source code

Data classes and parser implementations for incremental 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.

A parser is incremental, if it guarantees that for all i, j where i < j, all edges ending at i are built before any edges ending at j. This is appealing for, say, speech recognizer hypothesis filtering.

The main parser class is EarleyChartParser, which is a top-down algorithm, originally formulated by Jay Earley (1970).

Classes [hide private]
IncrementalChart
FeatureIncrementalChart
CompleteFundamentalRule
CompleterRule
ScannerRule
PredictorRule
FilteredCompleteFundamentalRule
FeatureCompleteFundamentalRule
FeatureCompleterRule
FeatureScannerRule
FeaturePredictorRule
IncrementalChartParser
An incremental chart parser implementing Jay Earley's parsing algorithm:
EarleyChartParser
IncrementalTopDownChartParser
IncrementalBottomUpChartParser
IncrementalBottomUpLeftCornerChartParser
IncrementalLeftCornerChartParser
FeatureIncrementalChartParser
FeatureEarleyChartParser
FeatureIncrementalTopDownChartParser
FeatureIncrementalBottomUpChartParser
FeatureIncrementalBottomUpLeftCornerChartParser
Functions [hide private]
 
demo(should_print_times=True, should_print_grammar=False, should_print_trees=True, trace=2, sent='I saw John with a dog with my cookie', numparses=5)
A demonstration of the Earley parsers.
source code
Variables [hide private]
  EARLEY_STRATEGY = [LeafInitRule(), TopDownInitRule(), Complete...
  TD_INCREMENTAL_STRATEGY = [LeafInitRule(), TopDownInitRule(), ...
  BU_INCREMENTAL_STRATEGY = [LeafInitRule(), EmptyPredictRule(),...
  BU_LC_INCREMENTAL_STRATEGY = BU_LC_INCREMENTAL_STRATEGY
  LC_INCREMENTAL_STRATEGY = [LeafInitRule(), FilteredBottomUpPre...
  EARLEY_FEATURE_STRATEGY = [LeafInitRule(), FeatureTopDownInitR...
  TD_INCREMENTAL_FEATURE_STRATEGY = [LeafInitRule(), FeatureTopD...
  BU_INCREMENTAL_FEATURE_STRATEGY = [LeafInitRule(), FeatureEmpt...
  BU_LC_INCREMENTAL_FEATURE_STRATEGY = [LeafInitRule(), FeatureE...
Variables Details [hide private]

EARLEY_STRATEGY

Value:
[LeafInitRule(), TopDownInitRule(), CompleterRule(), ScannerRule(), Pr\
edictorRule()]

TD_INCREMENTAL_STRATEGY

Value:
[LeafInitRule(), TopDownInitRule(), CachedTopDownPredictRule(), Comple\
teFundamentalRule()]

BU_INCREMENTAL_STRATEGY

Value:
[LeafInitRule(), EmptyPredictRule(), BottomUpPredictRule(), CompleteFu\
ndamentalRule()]

LC_INCREMENTAL_STRATEGY

Value:
[LeafInitRule(), FilteredBottomUpPredictCombineRule(), FilteredComplet\
eFundamentalRule()]

EARLEY_FEATURE_STRATEGY

Value:
[LeafInitRule(), FeatureTopDownInitRule(), FeatureCompleterRule(), Fea\
tureScannerRule(), FeaturePredictorRule()]

TD_INCREMENTAL_FEATURE_STRATEGY

Value:
[LeafInitRule(), FeatureTopDownInitRule(), FeatureTopDownPredictRule()\
, FeatureCompleteFundamentalRule()]

BU_INCREMENTAL_FEATURE_STRATEGY

Value:
[LeafInitRule(), FeatureEmptyPredictRule(), FeatureBottomUpPredictRule\
(), FeatureCompleteFundamentalRule()]

BU_LC_INCREMENTAL_FEATURE_STRATEGY

Value:
[LeafInitRule(), FeatureEmptyPredictRule(), FeatureBottomUpPredictComb\
ineRule(), FeatureCompleteFundamentalRule()]