nltk.parse.api module

class nltk.parse.api.ParserI[source]

Bases: object

A processing class for deriving trees that represent possible structures for a sequence of tokens. These tree structures are known as “parses”. Typically, parsers are used to derive syntax trees for sentences. But parsers can also be used to derive other kinds of tree structure, such as morphological trees and discourse structures.

Subclasses must define:
  • at least one of: parse(), parse_sents().

Subclasses may define:
  • grammar()


The grammar used by this parser.

parse(sent, *args, **kwargs)[source]

An iterator that generates parse trees for the sentence. When possible this list is sorted from most likely to least likely.


sent (list(str)) – The sentence to be parsed

Return type


parse_all(sent, *args, **kwargs)[source]
Return type


parse_one(sent, *args, **kwargs)[source]
Return type

Tree or None

parse_sents(sents, *args, **kwargs)[source]

Apply self.parse() to each element of sents. :rtype: iter(iter(Tree))