Package nltk :: Package parse :: Module api :: Class ParserI
[hide private]
[frames] | no frames]

type ParserI

source code

object --+
         |
        ParserI
Known Subclasses:

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:

Subclasses may define:

Instance Methods [hide private]
 
grammar(self)
Returns: The grammar used by this parser.
source code
Tree
parse(self, sent)
Returns: A parse tree that represents the structure of the given sentence, or None if no parse tree is found.
source code
list of Tree
nbest_parse(self, sent, n=None)
Returns: A list of parse trees that represent possible structures for the given sentence.
source code
iterator of Tree
iter_parse(self, sent)
Returns: An iterator that generates parse trees that represent possible structures for the given sentence.
source code
ProbDistI of Tree
prob_parse(self, sent)
Returns: A probability distribution over the possible parse trees for the given sentence.
source code
list of Tree
batch_parse(self, sents)
Apply self.parse() to each element of sents.
source code
list of list of Tree
batch_nbest_parse(self, sents, n=None)
Apply self.nbest_parse() to each element of sents.
source code
list of iterator of Tree
batch_iter_parse(self, sents)
Apply self.iter_parse() to each element of sents.
source code
list of ProbDistI of Tree
batch_prob_parse(self, sents)
Apply self.prob_parse() to each element of sents.
source code
    Deprecated
 
batch_test(self, filename)
 
get_parse(self, sent)
 
get_parse_dict(self, sent)
 
get_parse_list(self, sent)
 
get_parse_prob(self, sent)
Method Details [hide private]

grammar(self)

source code 
Returns:
The grammar used by this parser.

parse(self, sent)

source code 
Parameters:
  • sent (list of string) - The sentence to be parsed
Returns: Tree
A parse tree that represents the structure of the given sentence, or None if no parse tree is found. If multiple parses are found, then return the best parse.

nbest_parse(self, sent, n=None)

source code 
Parameters:
  • sent (list of string) - The sentence to be parsed
  • n (int) - The maximum number of trees to return.
Returns: list of Tree
A list of parse trees that represent possible structures for the given sentence. When possible, this list is sorted from most likely to least likely. If n is specified, then the returned list will contain at most n parse trees.

iter_parse(self, sent)

source code 
Parameters:
  • sent (list of string) - The sentence to be parsed
Returns: iterator of Tree
An iterator that generates parse trees that represent possible structures for the given sentence. When possible, this list is sorted from most likely to least likely.

prob_parse(self, sent)

source code 
Parameters:
  • sent (list of string) - The sentence to be parsed
Returns: ProbDistI of Tree
A probability distribution over the possible parse trees for the given sentence. If there are no possible parse trees for the given sentence, return a probability distribution that assigns a probability of 1.0 to None.

batch_parse(self, sents)

source code 

Apply self.parse() to each element of sents. I.e.:

>>> return [self.parse(sent) for sent in sents]
Returns: list of Tree

batch_nbest_parse(self, sents, n=None)

source code 

Apply self.nbest_parse() to each element of sents. I.e.:

>>> return [self.nbest_parse(sent, n) for sent in sents]
Returns: list of list of Tree

batch_iter_parse(self, sents)

source code 

Apply self.iter_parse() to each element of sents. I.e.:

>>> return [self.iter_parse(sent) for sent in sents]
Returns: list of iterator of Tree

batch_prob_parse(self, sents)

source code 

Apply self.prob_parse() to each element of sents. I.e.:

>>> return [self.prob_parse(sent) for sent in sents]
Returns: list of ProbDistI of Tree

batch_test(self, filename)

 
Decorators:
  • @deprecated("No longer supported.")

get_parse(self, sent)

 
Decorators:
  • @deprecated("Use parse() instead.")

get_parse_dict(self, sent)

 
Decorators:
  • @deprecated("Use prob_parse() instead.")

get_parse_list(self, sent)

 
Decorators:
  • @deprecated("Use nbest_parse() instead.")

get_parse_prob(self, sent)

 
Decorators:
  • @deprecated("Use prob_parse() instead.")