Skip to content

Instantly share code, notes, and snippets.

View hantek's full-sized avatar

Jonathan Zhouhan LIN hantek

  • Facebook; University de Montreal, Harbin Institute of Technology
  • Menlo Park, California, US
View GitHub Profile
@hantek
hantek / build_tree.py
Created August 11, 2021 09:42
distance to tree with different branching biases
#balanced tree construction
def build_tree(depth, sen):
assert len(depth) == len(sen)
assert len(depth) >= 0
if len(depth) == 1:
parse_tree = sen[0]
else:
idx_max = numpy.argmax(depth[1:]) + 1
parse_tree = []