tree

Tree is a very basic immutable tree class. A Tree can have multiple children and has one parent. The parent of a tree is established when a Tree is added as the child of another Tree.

API

Defines a base immutable tree type. This type can then be used to create a TokenTree which maps a sentence. This type is meant to be limited in scope and use and not as a general tree builder module.

class pyconll.tree.tree.Tree(data, children)[source]

A tree node. This is the base representation for a tree, which can have many children which are accessible via child index. The tree’s structure is immutable, so the parent and children cannot be changed once created.

__getitem__(key)[source]

Get specific children from the Tree. This can be an integer or slice.

Parameters:key – The indexer for the item.
__init__(data, children)[source]

Create a new tree with the desired properties.

Parameters:
  • data – The data to store on the tree.
  • children – The children of this node. None if there are no children.
__iter__()[source]

Provides an iterator over the children.

__len__()[source]

Provides the number of direct children on the tree.

Returns:The number of direct children on the tree.
children

Provides the children of the Tree. The property ensures it is readonly.

Returns:The list of children nodes.
parent

Provides the parent of the Tree. The property ensures it is readonly.

Returns:A pointer to the parent Tree reference.