Update ent_id of span and tokens #11113
-
I have a custom component where I need to update I've tried something like for t in span:
t.ent_id_ = "NEW_LABEL" which gives me the desired results. BUT when I then do |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
I've ended up creating a new span span = Span(doc, span.start, span.end, span_id="NEW_LABEL", label=span.label_)
doc.ents = [span] which seems to work as expected |
Beta Was this translation helpful? Give feedback.
-
I looked into this and although it doesn't look like there's directly a bug that we can address, this is definitely confusing because some span properties are separate copies of the token-level annotation and some are a view of the underlying token annotation. For getting or setting
The
For the code above, instead of setting token values within the span (that aren't reflected in the span = doc.ents[0]
span.id_ = "NEW_LABEL"
doc.ents = [span] Because the We'd like to make this more consistent in v4, feedback is welcome in #11328. |
Beta Was this translation helpful? Give feedback.
I've ended up creating a new span
which seems to work as expected