Upload BertForSyntaxParsing.py
Browse files- BertForSyntaxParsing.py +5 -1
BertForSyntaxParsing.py
CHANGED
@@ -189,7 +189,11 @@ class BertForSyntaxParsing(BertPreTrainedModel):
|
|
189 |
dep_func = ALL_FUNCTION_LABELS[funcs[i + 1]]
|
190 |
|
191 |
if dep_head == 'root': root_idx = len(tree)
|
192 |
-
tree.append(dict(word=toks[i], dep_head_idx=idx_mapping[dep_idx],
|
|
|
|
|
|
|
|
|
193 |
outputs.append(dict(tree=tree, root_idx=root_idx))
|
194 |
return outputs
|
195 |
|
|
|
189 |
dep_func = ALL_FUNCTION_LABELS[funcs[i + 1]]
|
190 |
|
191 |
if dep_head == 'root': root_idx = len(tree)
|
192 |
+
tree.append(dict(word=toks[i], dep_head_idx=idx_mapping[dep_idx], dep_func=dep_func))
|
193 |
+
# append the head word
|
194 |
+
for d in tree:
|
195 |
+
d['dep_head'] = tree[d['dep_head_idx']]['word']
|
196 |
+
|
197 |
outputs.append(dict(tree=tree, root_idx=root_idx))
|
198 |
return outputs
|
199 |
|