penman.tree¶
Definitions of tree structures.

class
penman.tree.
Tree
(node, metadata=None)[source]¶ A tree structure.
A tree is essentially a node that contains other nodes, but this Tree class is useful to contain any metadata and to provide treebased methods.

reset_variables
(fmt='{prefix}{j}')[source]¶ Recreate node variables formatted using fmt.
The fmt string can be formatted with the following values:
prefix
: first alphabetic character in the node’s concepti
: 0based index of the current occurrence of the prefixj
: 1based index starting from the second occurrence

walk
()[source]¶ Iterate over branches in the tree.
This function yields pairs of (path, branch) where each path is a tuple of 0based indices of branches to get to branch. For example, the path (2, 0) is the concept branch (‘/’, ‘bark01’) in the tree for the following PENMAN string, traversing first to the third (index 2) branch of the top node, then to the first (index 0) branch of that node:
(t / try01 :ARG0 (d / dog) :ARG1 (b / bark01 :ARG0 d))
The (path, branch) pairs are yielded in depthfirst order of the tree traversal.
