MCPcopy Create free account
hub / github.com/lazyprogrammer/machine_learning_examples / display_tree

Function display_tree

nlp_class2/util.py:81–92  ·  view source on GitHub ↗
(t, lvl=0)

Source from the content-addressed store, hash-verified

79
80
81def display_tree(t, lvl=0):
82 prefix = ''.join(['>']*lvl)
83 if t.word is not None:
84 print("%s%s %s" % (prefix, t.label, t.word))
85 else:
86 print("%s%s -" % (prefix, t.label))
87 # if t.left is None or t.right is None:
88 # raise Exception("Tree node has no word but left and right child are None")
89 if t.left:
90 display_tree(t.left, lvl + 1)
91 if t.right:
92 display_tree(t.right, lvl + 1)
93
94
95current_idx = 0

Callers 1

get_outputMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected