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

type ProjectiveDependencyParser

source code

object --+
         |
        ProjectiveDependencyParser

A projective, rule-based, dependency parser. A ProjectiveDependencyParser is created with a DependencyGrammar, a set of productions specifying word-to-word dependency relations. The parse() method will then return the set of all parses, in tree representation, for a given input sequence of tokens. Each parse must meet the requirements of the both the grammar and the projectivity constraint which specifies that the branches of the dependency tree are not allowed to cross. Alternatively, this can be understood as stating that each parent node and its children in the parse tree form a continuous substring of the input sequence.

Instance Methods [hide private]
 
__init__(self, dependency_grammar)
Create a new ProjectiveDependencyParser, from a word-to-word dependency grammar DependencyGrammar.
source code
a list of tree
parse(self, tokens)
Performs a projective dependency parse on the list of tokens using a chart-based, span-concatenation algorithm similar to Eisner (1996).
source code
 
concatenate(self, span1, span2)
Concatenates the two spans in whichever way possible.
source code
Method Details [hide private]

__init__(self, dependency_grammar)
(Constructor)

source code 

Create a new ProjectiveDependencyParser, from a word-to-word dependency grammar DependencyGrammar.

Parameters:
  • dependency_grammar (A DependencyGrammar.) - A word-to-word relation dependencygrammar.
Overrides: object.__init__

parse(self, tokens)

source code 

Performs a projective dependency parse on the list of tokens using a chart-based, span-concatenation algorithm similar to Eisner (1996).

Parameters:
  • tokens (a list of String) - The list of input tokens.
Returns: a list of tree
A list of parse trees.

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