huji-nlp / ucca

Universal Conceptual Cognitive Annotation (UCCA)
https://universalconceptualcognitiveannotation.github.io/
GNU General Public License v3.0
20 stars 20 forks source link

Error when removing a terminal (layer0) node from a layer1 graph #89

Closed nschneid closed 4 years ago

nschneid commented 4 years ago

When attempting to remove a terminal I get the following error:

    pu.remove(u)
  File "/Users/nathan/anaconda3/lib/python3.7/site-packages/ucca/core.py", line 129, in __call__
    return decorated(*args, **kwargs)
  File "/Users/nathan/anaconda3/lib/python3.7/site-packages/ucca/core.py", line 127, in decorated
    return self.fn(*args, **kwargs)
  File "/Users/nathan/anaconda3/lib/python3.7/site-packages/ucca/core.py", line 540, in remove
    if edge_or_node not in self._outgoing:  # a Node, or an error
  File "/Users/nathan/anaconda3/lib/python3.7/site-packages/ucca/layer0.py", line 109, in __eq__
    if other.layer.ID != LAYER_ID:
AttributeError: 'Edge' object has no attribute 'layer'

Is it possible to add a check to https://github.com/danielhers/ucca/blob/9487abbebb94b72ceb0153c803e0b8d851b5e70a/ucca/layer0.py#L109 to avoid this? Maybe:

if not hasattr(other, 'layer') or other.layer.ID != LAYER_ID: