Package nltk :: Package parse :: Module projectivedependencyparser :: Class ProbabilisticProjectiveDependencyParser
[hide private]
[frames] | no frames]

type ProbabilisticProjectiveDependencyParser

source code

object --+
         |
        ProbabilisticProjectiveDependencyParser

A probabilistic, projective dependency parser. This parser returns the most probable projective parse derived from the probabilistic dependency grammar derived from the train() method. The probabilistic model is an implementation of Eisner's (1996) Model C, which conditions on head-word, head-tag, child-word, and child-tag. The decoding uses a bottom-up chart-based span concatenation algorithm that's identical to the one utilized by the rule-based projective parser.

Instance Methods [hide private]
 
__init__(self)
Create a new probabilistic dependency parser.
source code
 
parse(self, tokens)
Parses the list of tokens subject to the projectivity constraint and the productions in the parser's grammar.
source code
 
concatenate(self, span1, span2)
Concatenates the two spans in whichever way possible.
source code
 
train(self, graphs)
Trains a StatisticalDependencyGrammar based on the list of input DependencyGraphs.
source code
 
compute_prob(self, dg)
Computes the probability of a dependency graph based on the parser's probability model (defined by the parser's statistical dependency grammar).
source code
Method Details [hide private]

__init__(self)
(Constructor)

source code 

Create a new probabilistic dependency parser. No additional operations are necessary.

Overrides: object.__init__

parse(self, tokens)

source code 

Parses the list of tokens subject to the projectivity constraint and the productions in the parser's grammar. This uses a method similar to the span-concatenation algorithm defined in Eisner (1996). It returns the most probable parse derived from the parser's probabilistic dependency grammar.

concatenate(self, span1, span2)

source code 

Concatenates the two spans in whichever way possible. This includes rightward concatenation (from the leftmost word of the leftmost span to the rightmost word of the rightmost span) and leftward concatenation (vice-versa) between adjacent spans. Unlike Eisner's presentation of span concatenation, these spans do not share or pivot on a particular word/word-index.

return: A list of new spans formed through concatenation. rtype: A list of DependencySpan

train(self, graphs)

source code 

Trains a StatisticalDependencyGrammar based on the list of input DependencyGraphs. This model is an implementation of Eisner's (1996) Model C, which derives its statistics from head-word, head-tag, child-word, and child-tag relationships.

param graphs: A list of dependency graphs to train from. type: A list of DependencyGraph

compute_prob(self, dg)

source code 

Computes the probability of a dependency graph based on the parser's probability model (defined by the parser's statistical dependency grammar).

param dg: A dependency graph to score. type dg: a DependencyGraph return: The probability of the dependency graph. rtype: A number/double.