Deleting Span where last token is newline char causes Type Error in rel.manual

When I render the json below in ner.manual, for Prodigy 1.11.8, deleting the first span ("melanoma (stage 4) neck"), yields the error below. Deleting the newline token at the end of the text (from the text and the tokens) fixes the issue, but I had to do this outside of Prodigy.

{'text': 'h/o melanoma (stage 4) neck 3/1993 - in remission :derm: dr. brad \n ',
 'spans': [{'text': 'melanoma (stage 4) neck',
   'start': 4,
   'token_start': 1,
   'token_end': 6,
   'end': 27,
   'type': 'span',
   'label': 'PROBLEM'},
  {'text': 'remission',
   'start': 40,
   'token_start': 10,
   'token_end': 10,
   'end': 49,
   'type': 'span',
   'label': 'SEVERITY'}],
 'tokens': [{'text': 'h/o',
   'start': 0,
   'end': 3,
   'id': 0,
   'ws': True,
   'disabled': False},
  {'text': 'melanoma',
   'start': 4,
   'end': 12,
   'id': 1,
   'ws': True,
   'disabled': False},
  {'text': '(',
   'start': 13,
   'end': 14,
   'id': 2,
   'ws': False,
   'disabled': False},
  {'text': 'stage',
   'start': 14,
   'end': 19,
   'id': 3,
   'ws': True,
   'disabled': False},
  {'text': '4',
   'start': 20,
   'end': 21,
   'id': 4,
   'ws': False,
   'disabled': False},
  {'text': ')',
   'start': 21,
   'end': 22,
   'id': 5,
   'ws': True,
   'disabled': False},
  {'text': 'neck',
   'start': 23,
   'end': 27,
   'id': 6,
   'ws': True,
   'disabled': False},
  {'text': '3/1993',
   'start': 28,
   'end': 34,
   'id': 7,
   'ws': True,
   'disabled': False},
  {'text': '-',
   'start': 35,
   'end': 36,
   'id': 8,
   'ws': True,
   'disabled': False},
  {'text': 'in',
   'start': 37,
   'end': 39,
   'id': 9,
   'ws': True,
   'disabled': False},
  {'text': 'remission',
   'start': 40,
   'end': 49,
   'id': 10,
   'ws': True,
   'disabled': False},
  {'text': ':',
   'start': 50,
   'end': 51,
   'id': 11,
   'ws': False,
   'disabled': False},
  {'text': 'derm',
   'start': 51,
   'end': 55,
   'id': 12,
   'ws': False,
   'disabled': False},
  {'text': ':',
   'start': 55,
   'end': 56,
   'id': 13,
   'ws': True,
   'disabled': False},
  {'text': 'dr',
   'start': 57,
   'end': 59,
   'id': 14,
   'ws': False,
   'disabled': False},
  {'text': '.',
   'start': 59,
   'end': 60,
   'id': 15,
   'ws': True,
   'disabled': False},
  {'text': 'brad',
   'start': 61,
   'end': 65,
   'id': 16,
   'ws': True,
   'disabled': False},
  {'text': '\n ',
   'start': 66,
   'end': 68,
   'id': 17,
   'ws': True,
   'disabled': False}],
 '_input_hash': -1984187279,
 '_task_hash': -1693069130,
 '_is_binary': False,
 '_view_id': 'relations',
 'relations': [{'head': 10,
   'child': 6,
   'head_span': {'start': 40,
    'end': 49,
    'token_start': 10,
    'token_end': 10,
    'label': 'SEVERITY'},
   'child_span': {'start': 4,
    'end': 27,
    'token_start': 1,
    'token_end': 6,
    'label': 'PROBLEM'},
   'color': '#ffd882',
   'label': 'sev_to_ent'}],
 'answer': 'accept',
 '_timestamp': 1663605111}

`TypeError: Cannot read properties of undefined (reading 'y')

in t
in Jss(t)
in div
in t
in Jss(t)
in Unknown
in t
in Jss(t)
in div
in div
in t
in Jss(t)
in Connect(Jss(t))
in main
in div
in Shortcuts
in t
in n
in Jss(n)
in Connect(Jss(n))
in t
in t
in Connect(t)
in t
in t`

A related issue here is trying to create a new span with a newline character in the middle using the rel.manual recipe . For example, if you load the json below and then try to create a new span of 'fdg avid small \nmass', you are likely to be prohibited as in the screenshot. I can get around this by removing the newline character and adjusting the text, tokens, and spans, but ideally either Prodigy could do this under the hood or it could allow the formation of these kinds of spans, as other recipes must allow.

{'text': 'liver left lobe fdg avid small \nmass is also probably metastatic.',
 '_input_hash': 1195389150,
 '_task_hash': -502830353,
 'tokens': [{'text': 'liver',
   'start': 0,
   'end': 5,
   'id': 0,
   'ws': True,
   'disabled': False},
  {'text': 'left',
   'start': 6,
   'end': 10,
   'id': 1,
   'ws': True,
   'disabled': False},
  {'text': 'lobe',
   'start': 11,
   'end': 15,
   'id': 2,
   'ws': True,
   'disabled': False},
  {'text': 'fdg',
   'start': 16,
   'end': 19,
   'id': 3,
   'ws': True,
   'disabled': False},
  {'text': 'avid',
   'start': 20,
   'end': 24,
   'id': 4,
   'ws': True,
   'disabled': False},
  {'text': 'small',
   'start': 25,
   'end': 30,
   'id': 5,
   'ws': True,
   'disabled': False},
  {'text': '\n',
   'start': 31,
   'end': 32,
   'id': 6,
   'ws': False,
   'disabled': False},
  {'text': 'mass',
   'start': 32,
   'end': 36,
   'id': 7,
   'ws': True,
   'disabled': False},
  {'text': 'is',
   'start': 37,
   'end': 39,
   'id': 8,
   'ws': True,
   'disabled': False},
  {'text': 'also',
   'start': 40,
   'end': 44,
   'id': 9,
   'ws': True,
   'disabled': False},
  {'text': 'probably',
   'start': 45,
   'end': 53,
   'id': 10,
   'ws': True,
   'disabled': False},
  {'text': 'metastatic',
   'start': 54,
   'end': 64,
   'id': 11,
   'ws': False,
   'disabled': False},
  {'text': '.',
   'start': 64,
   'end': 65,
   'id': 12,
   'ws': False,
   'disabled': False}],
 'spans': [{'text': 'metastatic',
   'start': 54,
   'token_start': 11,
   'token_end': 11,
   'end': 64,
   'type': 'span',
   'label': 'SEVERITY'}],
 '_view_id': 'relations',
 'answer': 'accept',
 '_timestamp': 1660151777,
 '_is_binary': False,
 'relations': [{'head': 11,
   'child': 7,
   'head_span': {'start': 54,
    'end': 64,
    'token_start': 11,
    'token_end': 11,
    'label': 'SEVERITY'},
   'child_span': {'start': 0,
    'end': 36,
    'token_start': 0,
    'token_end': 7,
    'label': 'PROBLEM'},
   'color': '#ffd882',
   'label': 'sev_to_ent'}]}

To prevent lots of scrolling, could you wrap the json examples in code blocks using tics (```)? Responding is a bit easier if there's less scrolling involved. I've now manually made the change myself on your posts.

Just to check, I think this might be a duplicate of this. Am I correct? For now the solution is to manually remove the \n characters. It's an issue in our front-end that the team is aware of.

1 Like