udapi/udapi-python

Problem with deps and Null Nodes

francescomambrini opened this issue · 2 comments

If you create an Empty Node with a decimal ord (e.g. 17.1) and set deps to it with something like: n.deps.append({'parent': empty, 'deprel': 'dep'}, only the whole part of the float is serialized by the CoNLL-U writer. Therefore, the wrong secondary edge is created in the CoNLL-U output (17:dep, instead of 17.1:dep).

I suspect the problem is in the raw_deps attribute of the Node class, lines 197-199:

 for secondary_dependence in self._deps:
                serialized_deps.append('%d:%s' % (secondary_dependence[
                    'parent'].ord, secondary_dependence['deprel']))

as %d will only return a whole number.

Thanks!

Thanks for the bugreport. This seems possible (empty nodes and enhanced deps are not well tested). Can you send a PR, please?
Ideally with a test. I am quite busy now even for such small bugfixes.

Sure! I'll work on it.
It might be a bit complicated, because I played around with my fork (I didn't think I might actually have anything to contribute, but I'll be super-happy to do it). Rebasing everything is probably going to be the hardest part of the fix... :-)