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

Package parse

source code

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:

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:

Submodules [hide private]

Classes [hide private]
  EarleyChartParser
A chart parser implementing the Earley parsing algorithm:
  FeatureEarleyChartParser
A chart parser implementing the Earley parsing algorithm, allowing nonterminals that have features (known as FeatStructNonterminals).
  SteppingChartParser
A ChartParser that allows you to step through the parsing process, adding a single edge at a time.
  ChartParser
A generic chart parser.
  InsideChartParser
A bottom-up parser for PCFGs that tries edges in descending order of the inside probabilities of their trees.
  BottomUpChartParser
An abstract bottom-up parser for PCFGs that uses a Chart to record partial results.
  LongestChartParser
A bottom-up parser for PCFGs that tries longer edges before shorter ones.
  RandomChartParser
A bottom-up parser for PCFGs that tries edges in random order.
  UnsortedChartParser
A bottom-up parser for PCFGs that tries edges in whatever order.
  SteppingRecursiveDescentParser
A RecursiveDescentParser that allows you to step through the parsing process, performing a single operation at a time.
  RecursiveDescentParser
A simple top-down CFG parser that parses texts by recursively expanding the fringe of a Tree, and matching it against a text.
  SteppingShiftReduceParser
A ShiftReduceParser that allows you to setp through the parsing process, performing a single operation at a time.
  ShiftReduceParser
A simple bottom-up CFG parser that uses two operations, "shift" and "reduce", to find a single parse for a text.
  ViterbiParser
A bottom-up PCFG parser that uses dynamic programming to find the single most likely parse for a text.
  ParserI
A processing class for deriving trees that represent possible structures for a sequence of tokens.
    Deprecated
  ParseI
Use nltk.ParserI instead.
  AbstractParse
Use nltk.ParserI instead.
  RecursiveDescent
Use nltk.RecursiveDescentParser instead.
  SteppingRecursiveDescent
Use nltk.SteppingRecursiveDescentParser instead.
  ShiftReduce
Use nltk.ShiftReduceParser instead.
  SteppingShiftReduce
Use nltk.SteppingShiftReduceParser instead.
  EarleyChartParse
Use nltk.EarleyChartParser instead.
  FeatureEarleyChartParse
Use nltk.FeatureEarleyChartParser instead.
  ChartParse
Use nltk.ChartParser instead.
  SteppingChartParse
Use nltk.SteppingChartParser instead.
  BottomUpChartParse
Use nltk.BottomUpChartParser instead.
  InsideParse
Use nltk.InsideChartParser instead.
  RandomParse
Use nltk.RandomChartParser instead.
  UnsortedParse
Use nltk.UnsortedChartParser instead.
  LongestParse
Use nltk.LongestChartParser instead.
  ViterbiParse
Use nltk.ViterbiParser instead.
  GrammarFile
Use nltk.data.load() instead.