Passage

class ucca.core.Passage(ID, attrib=None)[source]

Bases: object

An annotated text with UCCA annotation graph.

A Passage is an object representing a text annotated with UCCA annotation. UCCA annotation is a directed acyclic graph of Node and Edge objects grouped into Layer objects.

Attributes:
ID: ID of the Passage root: simply self, for API similarity with other UCCA objects attrib: attribute dictionary of the Passage extra: temporary storage space for undocumented attributes and data layers: all Layers of the Passage, no order guaranteed nodes: dictionary of ID-node pairs for all the nodes in the Passage frozen: indicates whether the Passage can be modified or not, boolean.

Attributes Summary

ID
attrib
categories
layers
nodes
refined_categories
root

Methods Summary

by_id(ID) Returns a Node whose ID is given.
copy([layers]) Copies the Passage and specified layers to a new object.
equals(other, *[, ordered, ignore_node, …]) Returns whether two passages are equivalent.
layer(ID) Returns the Layer object whose ID is given.
missing_nodes(other[, ignore_node, ignore_edge]) Returns nodes present in this passage but missing in the other.

Attributes Documentation

ID
attrib
categories
layers
nodes
refined_categories
root

Methods Documentation

by_id(ID)[source]

Returns a Node whose ID is given.

Parameters:ID – ID string
Returns:The node.Node object whose ID matches
Raises:KeyError – if no Node with this ID is found
copy(layers=None)[source]

Copies the Passage and specified layers to a new object.

The main “building block” of copying is the Layer, so copying is truly copying the Passage attributes (attrib, extra, ID, frozen) and creating the equivalent layers (each layer for itself).

Parameters:layers – sequence of layer IDs to copy to the new object. If None, all layers will be copied.
Returns:A new Passage object.
Raises:KeyError – if a given layer ID doesn’t exist. UnimplementedMethodError if copying for a layer is unimplemented.
equals(other, *, ordered=False, ignore_node=None, ignore_edge=None)[source]

Returns whether two passages are equivalent.

Passage-equivalence is determined by having the same attributes and all layers (according to ID) are Layer-equivalent.

Parameters:
  • other – the Passage object to compare to
  • ordered – is Layer-equivalency should be ordered (see there)
  • ignore_node – function that returns whether to ignore a given node
  • ignore_edge – function that returns whether to ignore a given edge
Returns:

True iff self is Passage-equivalent to other.

layer(ID)[source]

Returns the Layer object whose ID is given.

Parameters:ID – ID of the Layer requested.
Raises:KeyError – if no Layer with this ID is present
missing_nodes(other, ignore_node=None, ignore_edge=None)[source]

Returns nodes present in this passage but missing in the other.

Parameters:
  • other – the Passage object to compare to
  • ignore_node – function that returns whether to ignore a given node
  • ignore_edge – function that returns whether to ignore a given edge
Returns:

List of nodes present in this passage but missing in the other.