Example #1
0
def make_zssNode_from_tuple(t):
    """Convert my tuple representation into the Node object
    representation used in zss."""
    n = Node(t[0])
    for s in t[1:]:
        n.addkid(make_zssNode_from_tuple(s))
    return n
Example #2
0
 def addnode(t, i):
     if i >= 0:
         n = ZSNode(names[i])
     else:
         n = ZSNode('c')
         tn = t[-i - 1]
         for k in [tn.left, tn.right]:
             n.addkid(addnode(t, k))
     return n
Example #3
0
def T(tree):
    root = Node(tree.get_key())
    for c in tree.get_children():
        root.addkid(T(c))
    return root
Example #4
0
def _dict2zt(d):
    n = ZSNode(d['lab'])
    for kn in d['kids']:
        n.addkid(_dict2zt(kn))
    return n