Node¶
-
class
ucca.core.
Node
(ID, root, tag, attrib=None, *, orderkey=<function edge_id_orderkey>)[source]¶ Bases:
object
Labeled Node in UCCA annotation graph.
A Node in
Passage
UCCA annotation is an vertex in the annotation graph, which may be an internal vertex or a leaf, and is labeled with a tag that specifies both theLayer
it belongs to and it’s ID in this Layer. It can have multiple children Nodes throughEdge
objects, and these children are ordered according to an internal order function.- Attributes:
- ID: ID of the Node, constructed from the ID of the Layer it belongs to,
- a separator, and a unique alphanumeric ID in the layer.
root: the Passage this object is linked with attrib: attribute dictionary of the Node extra: temporary storage space for undocumented attributes and data tag: the string label of the Node layer: the Layer this Node belongs to incoming: a copy of the incoming Edges to this object outgoing: a copy of the outgoing Edges from this object parents: the Nodes which have incoming Edges to this object children: the Nodes which have outgoing Edges from this object orderkey: the key function for ordering the outgoing Edges ID_SEPARATOR: separator function between the Layer ID and the unique
Node ID in the complete ID of the Node. Mustn’t be alphanumeric.
Attributes Summary
ID
ID_SEPARATOR
add
add_multiple
attrib
children
destroy
incoming
layer
orderkey
outgoing
parents
remove
root
tag
Methods Summary
equals
(other, *[, recursive, ordered, …])Returns whether the self Node-equals other. get_terminals
(*args, **kwargs)Returns a list of all terminals under the span of this Node. iter
([obj, method, duplicates, key])Iterates the Node
objects in the subtree of self.missing_edges
(other[, ignore_node])Returns edges present in this node but missing in the other. Attributes Documentation
-
ID
¶
-
ID_SEPARATOR
= '.'¶
-
add
= functools.partial(<bound method ModifyPassage.__call__ of <ucca.core.ModifyPassage object>>, None)¶
-
add_multiple
= functools.partial(<bound method ModifyPassage.__call__ of <ucca.core.ModifyPassage object>>, None)¶
-
attrib
¶
-
children
¶
-
destroy
= functools.partial(<bound method ModifyPassage.__call__ of <ucca.core.ModifyPassage object>>, None)¶
-
incoming
¶
-
layer
¶
-
orderkey
¶
-
outgoing
¶
-
parents
¶
-
remove
= functools.partial(<bound method ModifyPassage.__call__ of <ucca.core.ModifyPassage object>>, None)¶
-
root
¶
-
tag
¶
Methods Documentation
-
equals
(other, *, recursive=True, ordered=False, ignore_node=None, ignore_edge=None)[source]¶ Returns whether the self Node-equals other.
Node-equality is basically determined by self and other having the same tag and attributes. Recursive equality is achieved when all outgoing Edges are Edge-equal, and their children are recursively Node-equal as well. Ordered equality means that the outgoing Edges should be equivalent to each other w.r.t order (the first to the first etc.), while unordered equality means that each Edges are equivalent after being ordered with some determined order.
Parameters: - other – the Node object to compare to
- recursive – whether comparison is recursive, defaults to True.
- ordered – whether comparison should include strict ordering
- 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 the Nodes are equal in the terms given.
-
get_terminals
(*args, **kwargs)[source]¶ Returns a list of all terminals under the span of this Node.
-
iter
(obj='nodes', method='dfs', duplicates=False, key=None)[source]¶ Iterates the
Node
objects in the subtree of self.Parameters: obj – - yield Node objects (use value “nodes”, default) or Edge
- objects (use values “edges”)
- method: do breadth-first iteration (use value “bfs”) or depth-first
- iteration (value “dfs”, default).
- duplicates: If True, may return the same object twice if it is
- encountered twice, because of the DAG structure which isn’t necessarily a tree. If it is False, all objects will be yielded only the first time they are encountered. Defaults to False.
- key: boolean function that filters the iterable items. key function
- takes one argument (the item) and returns True if it should be returned to the user. If an item isn’t returned, its subtree is still iterated. Defaults to None (returns all items).