Package nltk_lite :: Package contrib :: Package dependency :: Module deptree :: Class DepGraph
[hide private]
[frames] | no frames]

Class DepGraph

source code

object --+
         |
        DepGraph

A container for the nodes and labelled edges of a dependency structure.

Instance Methods [hide private]
 
__init__(self)
We place a dummy 'top' node in the first position in the nodelist, since the root node is often assigned '0' as its head.
source code
 
__str__(self)
str(x)
source code
 
load(self, file) source code
 
_normalize(self, line)
Deal with lines in which spaces are used rather than tabs.
source code
 
read(self, input) source code
 
_word(self, node, filter=True) source code
 
_deptree(self, i)
Recursive function for turning dependency graphs into NLTK trees.
source code
 
deptree(self)
Starting with the root node, build a dependency tree using the NLTK Tree constructor.
source code
 
_hd(self, i) source code
 
_rel(self, i) source code
XDigraph
nx_graph(self)
Convert the data in a nodelist into a networkx labeled directed graph.
source code

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

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self)
(Constructor)

source code 

We place a dummy 'top' node in the first position in the nodelist, since the root node is often assigned '0' as its head. This also means that the indexing of the nodelist corresponds directly to the Malt-TAB format, which starts at 1.

Overrides: object.__init__

__str__(self)
(Informal representation operator)

source code 

str(x)

Overrides: object.__str__
(inherited documentation)

load(self, file)

source code 
Parameters:
  • file - a file in Malt-TAB format

read(self, input)

source code 
Parameters:
  • input - a string in Malt-TAB format

_deptree(self, i)

source code 

Recursive function for turning dependency graphs into NLTK trees.

Parameters:
  • i (int) - index of a node in nodelist
Returns:
either a word (if the indexed node is a leaf) or a Tree.

deptree(self)

source code 

Starting with the root node, build a dependency tree using the NLTK Tree constructor. Dependency labels are omitted.