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

Class 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]
list of iterator of Tree
batch_iter_parse(self, sents)
Apply self.iter_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 Tree
batch_parse(self, sents)
Apply self.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
 
grammar(self)
Returns: The grammar used by this parser.
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
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
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
ProbDistI of Tree
prob_parse(self, sent)
Returns: A probability distribution over the possible parse trees for the given sentence.
source code

Inherited from object: __delattr__, __getattribute__, __hash__, __init__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

    Deprecated
 
batch_test(*args, **kwargs) source code
 
get_parse(*args, **kwargs) source code
 
get_parse_dict(*args, **kwargs) source code
 
get_parse_list(*args, **kwargs) source code
 
get_parse_prob(*args, **kwargs) source code
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

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_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_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_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(*args, **kwargs)

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

Deprecated: No longer supported.

get_parse(*args, **kwargs)

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

Deprecated: Use parse() instead.

get_parse_dict(*args, **kwargs)

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

Deprecated: Use prob_parse() instead.

get_parse_list(*args, **kwargs)

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

Deprecated: Use nbest_parse() instead.

get_parse_prob(*args, **kwargs)

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

Deprecated: Use prob_parse() instead.

grammar(self)

source code 
Returns:
The grammar used by this parser.

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.

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.

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.

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.