tree¶
Tree
is a very basic immutable tree class. A Tree
can have multiple children and has one parent. The parent and child of a tree are established when a Tree
is created. Accessing the data on a Tree
can be done through the data
member.
API¶
Defines a base immutable tree type. This type can then be used to create a SentenceTree 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.
-
__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. None if there is no parent.
-