Skip to content
Snippets Groups Projects
Commit 4b3e1caf authored by Mateusz Klimaszewski's avatar Mateusz Klimaszewski
Browse files

Handle double > cases.

parent 4eaad34d
Branches
Tags
2 merge requests!37Release 1.0.4.,!36Release 1.0.4
......@@ -114,13 +114,31 @@ def restore_collapse_edges(tree_tokens):
head, relation = d.split(':', 1)
ehead = f"{len(tree_tokens)}.{len(empty_tokens) + 1}"
empty_node_relation, current_node_relation = relation.split(">", 1)
deps[i] = f"{ehead}:{current_node_relation}"
empty_tokens.append(
{
"id": ehead,
"deps": f"{head}:{empty_node_relation}"
}
)
# Edge case, double >
if ">" in current_node_relation:
second_empty_node_relation, current_node_relation = current_node_relation.split(">")
deps[i] = f"{ehead}:{current_node_relation}"
empty_tokens.append(
{
"id": ehead,
"deps": f"{head}:{empty_node_relation}"
}
)
empty_tokens.append(
{
"id": f"{len(tree_tokens)}.{len(empty_tokens) + 1}",
"deps": f"{ehead}:{second_empty_node_relation}"
}
)
else:
deps[i] = f"{ehead}:{current_node_relation}"
empty_tokens.append(
{
"id": ehead,
"deps": f"{head}:{empty_node_relation}"
}
)
deps = sorted([d.split(":", 1) for d in deps], key=lambda x: float(x[0]))
token["deps"] = "|".join([f"{k}:{v}" for k, v in deps])
return empty_tokens
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment