def vvBinarize(tr):
children = []
vvIndex = None
for i, child in enumerate(tr):
children.append(child)
if child.node in vvTags:
vvIndex = i
if vvIndex == None:
print >> sys.stderr, "no vv in the children!!!",
output(tr)
return
tmpNode = nltk.Tree("(X)")
for i in xrange(vvIndex, len(tr)):
tmpNode.append(children[i])
leftBinarize(tmpNode)
while len(tr) > vvIndex:
tr.pop()
tr.append(tmpNode)
rightBinarize(tr)
评论列表
文章目录