udapi.core.bundle module

Bundle class represents one sentence.

class udapi.core.bundle.Bundle(bundle_id=None, document=None)[source]

Bases: object

Bundle represents one sentence in an UD document.

A bundle contains one or more trees. More trees are needed e.g. in case of parallel treebanks where each tree represents a translation of the sentence in a different languages. Trees in one bundle are distinguished by a zone label.

add_tree(root)[source]

Add an existing tree to the bundle.

address()[source]

Return bundle_id or ‘?’ if missing.

property bundle_id

ID of this bundle.

check_zone(new_zone)[source]

Raise an exception if the zone is invalid or already exists.

create_tree(zone=None)[source]

Return the root of a newly added tree with a given zone.

property document

Returns the document in which the bundle is contained.

draw(**kwargs)[source]

Pretty print the trees using TextModeTrees.

get_tree(zone='')[source]

Returns the tree root whose zone is equal to zone.

has_tree(zone='')[source]

Does this bundle contain a tree with a given zone?

property nodes

An iterator over all nodes (excluding empty nodes) in all trees in this bundle.

number
remove()[source]

Remove a bundle from the document.

trees