nltk.parse package¶
Submodules¶
- nltk.parse.api module
- nltk.parse.bllip module
- nltk.parse.chart module
AbstractChartRule
BottomUpChartParser
BottomUpLeftCornerChartParser
BottomUpPredictCombineRule
BottomUpPredictRule
CachedTopDownPredictRule
Chart
Chart.__init__()
Chart.child_pointer_lists()
Chart.dot_digraph()
Chart.edges()
Chart.initialize()
Chart.insert()
Chart.insert_with_backpointer()
Chart.iteredges()
Chart.leaf()
Chart.leaves()
Chart.num_edges()
Chart.num_leaves()
Chart.parses()
Chart.pretty_format()
Chart.pretty_format_edge()
Chart.pretty_format_leaves()
Chart.select()
Chart.trees()
ChartParser
ChartRuleI
EdgeI
EmptyPredictRule
FilteredBottomUpPredictCombineRule
FilteredSingleEdgeFundamentalRule
FundamentalRule
LeafEdge
LeafInitRule
LeftCornerChartParser
SingleEdgeFundamentalRule
SteppingChartParser
SteppingChartParser.__init__()
SteppingChartParser.chart()
SteppingChartParser.current_chartrule()
SteppingChartParser.grammar()
SteppingChartParser.initialize()
SteppingChartParser.parse()
SteppingChartParser.parses()
SteppingChartParser.set_chart()
SteppingChartParser.set_grammar()
SteppingChartParser.set_strategy()
SteppingChartParser.step()
SteppingChartParser.strategy()
TopDownChartParser
TopDownInitRule
TopDownPredictRule
TreeEdge
demo()
demo_grammar()
- nltk.parse.corenlp module
CoreNLPDependencyParser
CoreNLPParser
CoreNLPServer
CoreNLPServerError
GenericCoreNLPParser
GenericCoreNLPParser.__init__()
GenericCoreNLPParser.api_call()
GenericCoreNLPParser.parse_sents()
GenericCoreNLPParser.parse_text()
GenericCoreNLPParser.raw_parse()
GenericCoreNLPParser.raw_parse_sents()
GenericCoreNLPParser.raw_tag_sents()
GenericCoreNLPParser.tag()
GenericCoreNLPParser.tag_sents()
GenericCoreNLPParser.tokenize()
transform()
try_port()
- nltk.parse.dependencygraph module
DependencyGraph
DependencyGraph.__init__()
DependencyGraph.add_arc()
DependencyGraph.add_node()
DependencyGraph.connect_graph()
DependencyGraph.contains_address()
DependencyGraph.contains_cycle()
DependencyGraph.get_by_address()
DependencyGraph.get_cycle_path()
DependencyGraph.left_children()
DependencyGraph.load()
DependencyGraph.nx_graph()
DependencyGraph.redirect_arcs()
DependencyGraph.remove_by_address()
DependencyGraph.right_children()
DependencyGraph.to_conll()
DependencyGraph.to_dot()
DependencyGraph.tree()
DependencyGraph.triples()
DependencyGraphError
conll_demo()
conll_file_demo()
cycle_finding_demo()
demo()
dot2img()
malt_demo()
- nltk.parse.earleychart module
CompleteFundamentalRule
CompleterRule
EarleyChartParser
FeatureCompleteFundamentalRule
FeatureCompleterRule
FeatureEarleyChartParser
FeatureIncrementalBottomUpChartParser
FeatureIncrementalBottomUpLeftCornerChartParser
FeatureIncrementalChart
FeatureIncrementalChartParser
FeatureIncrementalTopDownChartParser
FeaturePredictorRule
FeatureScannerRule
FilteredCompleteFundamentalRule
IncrementalBottomUpChartParser
IncrementalBottomUpLeftCornerChartParser
IncrementalChart
IncrementalChartParser
IncrementalLeftCornerChartParser
IncrementalTopDownChartParser
PredictorRule
ScannerRule
demo()
- nltk.parse.evaluate module
- nltk.parse.featurechart module
FeatureBottomUpChartParser
FeatureBottomUpLeftCornerChartParser
FeatureBottomUpPredictCombineRule
FeatureBottomUpPredictRule
FeatureChart
FeatureChartParser
FeatureEmptyPredictRule
FeatureFundamentalRule
FeatureSingleEdgeFundamentalRule
FeatureTopDownChartParser
FeatureTopDownInitRule
FeatureTopDownPredictRule
FeatureTreeEdge
InstantiateVarsChart
demo()
demo_grammar()
run_profile()
- nltk.parse.generate module
- nltk.parse.malt module
- nltk.parse.nonprojectivedependencyparser module
DemoScorer
DependencyScorerI
NaiveBayesDependencyScorer
NonprojectiveDependencyParser
ProbabilisticNonprojectiveParser
ProbabilisticNonprojectiveParser.__init__()
ProbabilisticNonprojectiveParser.best_incoming_arc()
ProbabilisticNonprojectiveParser.collapse_nodes()
ProbabilisticNonprojectiveParser.compute_max_subtract_score()
ProbabilisticNonprojectiveParser.compute_original_indexes()
ProbabilisticNonprojectiveParser.initialize_edge_scores()
ProbabilisticNonprojectiveParser.original_best_arc()
ProbabilisticNonprojectiveParser.parse()
ProbabilisticNonprojectiveParser.train()
ProbabilisticNonprojectiveParser.update_edge_scores()
demo()
hall_demo()
nonprojective_conll_parse_demo()
rule_based_demo()
- nltk.parse.pchart module
- nltk.parse.projectivedependencyparser module
- nltk.parse.recursivedescent module
RecursiveDescentParser
SteppingRecursiveDescentParser
SteppingRecursiveDescentParser.__init__()
SteppingRecursiveDescentParser.backtrack()
SteppingRecursiveDescentParser.currently_complete()
SteppingRecursiveDescentParser.expand()
SteppingRecursiveDescentParser.expandable_productions()
SteppingRecursiveDescentParser.frontier()
SteppingRecursiveDescentParser.initialize()
SteppingRecursiveDescentParser.match()
SteppingRecursiveDescentParser.parse()
SteppingRecursiveDescentParser.parses()
SteppingRecursiveDescentParser.remaining_text()
SteppingRecursiveDescentParser.set_grammar()
SteppingRecursiveDescentParser.step()
SteppingRecursiveDescentParser.tree()
SteppingRecursiveDescentParser.untried_expandable_productions()
SteppingRecursiveDescentParser.untried_match()
demo()
- nltk.parse.shiftreduce module
ShiftReduceParser
SteppingShiftReduceParser
SteppingShiftReduceParser.__init__()
SteppingShiftReduceParser.initialize()
SteppingShiftReduceParser.parse()
SteppingShiftReduceParser.parses()
SteppingShiftReduceParser.reduce()
SteppingShiftReduceParser.reducible_productions()
SteppingShiftReduceParser.remaining_text()
SteppingShiftReduceParser.set_grammar()
SteppingShiftReduceParser.shift()
SteppingShiftReduceParser.stack()
SteppingShiftReduceParser.step()
SteppingShiftReduceParser.undo()
demo()
- nltk.parse.stanford module
- nltk.parse.transitionparser module
- nltk.parse.util module
- nltk.parse.viterbi module
Module contents¶
NLTK Parsers
Classes and interfaces for producing tree structures that represent the internal organization of a text. This task is known as “parsing” the text, and the resulting tree structures are called the text’s “parses”. Typically, the text is a single sentence, and the tree structure represents the syntactic structure of the sentence. However, parsers can also be used in other domains. For example, parsers can be used to derive the morphological structure of the morphemes that make up a word, or to derive the discourse structure for a set of utterances.
Sometimes, a single piece of text can be represented by more than one tree structure. Texts represented by more than one tree structure are called “ambiguous” texts. Note that there are actually two ways in which a text can be ambiguous:
The text has multiple correct parses.
There is not enough information to decide which of several candidate parses is correct.
However, the parser module does not distinguish these two types of ambiguity.
The parser module defines ParserI
, a standard interface for parsing
texts; and two simple implementations of that interface,
ShiftReduceParser
and RecursiveDescentParser
. It also contains
three sub-modules for specialized kinds of parsing:
nltk.parser.chart
defines chart parsing, which uses dynamic programming to efficiently parse texts.
nltk.parser.probabilistic
defines probabilistic parsing, which associates a probability with each parse.