Open dan-zeman opened 3 years ago
Related: If there is an empty node in the sentence, its ID is not updated, so it ends up between different nodes than where it was originally.
After two years, I ran into this issue again. The following ugly workaround seems to help with the enhanced relations but not with the position of the empty nodes. It might be useful until the bug is fixed properly.
# Bug in Udapi: shift_before_node() does not update enhanced relations.
# Before using the method, deserialize the whole graph, i.e., convert
# parent node ids to parent node object references.
egraph = []
if len(node.deps) > 0:
for n in node.root.descendants_and_empty:
edeps = []
for ed in n.deps:
edeps.append({'parent': ed['parent'], 'deprel': ed['deprel']})
egraph.append((n, edeps))
# Now shift the node, which will update numeric IDs (ords) of all
# subsequent node objects.
numbernode.shift_before_node(node)
# Not sure if this is needed: Re-set the edeps to make sure that
# Udapi will have to serialize the egraph with the updated numbers.
for eg in egraph:
n = eg[0]
edeps = eg[1]
n.deps = edeps
I have the following code to fix tokenization issues in Spanish AnCora (https://github.com/UniversalDependencies/UD_Spanish-AnCora/issues/6):
The method
shift_after_node()
correctly updates ids and basic heads that are after the new position of the shifted node. Unfortunately it fails to also update the enhanced heads when enhanced representation is present. Hence the following sourceresults in the following (note the mismatch in the parent of the preposition con):
It just occurred to me that the
MentionSpan
would also need updating but for that one would probably need to activate the CorefUD sub-API first?