udapi.core.document module

Document class is a container for UD trees.

class udapi.core.document.Document(filename=None, **kwargs)[source]

Bases: object

Document is a container for Universal Dependency trees.

property coref_clusters

DEPRECATED: A dict mapping eid to a CorefEntity object.

Substitute doc.coref_clusters.values() and list(doc.coref_clusters.values()) with doc.coref_entities. Otherwise, substitute doc.coref_clusters with doc.eid_to_entity.

property coref_entities

A list of all CorefEntity objects in the document.

property coref_mentions

A sorted list of all CorefMention objects in the document.

create_bundle()[source]

Create a new bundle and add it at the end of the document.

create_coref_entity(eid=None, etype=None)[source]
draw(**kwargs)[source]

Pretty print the trees using TextModeTrees.

property eid_to_entity

A dict mapping each eid (entity ID) to a CorefEntity object.

from_conllu_string(string)[source]

Load a document from a conllu-formatted string.

load_conllu(filename=None, **kwargs)[source]

Load a document from a conllu-formatted file.

property nodes

An iterator over all nodes (excluding empty nodes) in the document.

property nodes_and_empty

An iterator over all nodes and empty nodes in the document.

store_conllu(filename)[source]

Store a document into a conllu-formatted file.

to_conllu_string()[source]

Return the document as a conllu-formatted string.

property trees

An iterator over all trees in the document.