Given a token which is part of a named entity with multiple tokens, is there a direct method to get the span of that entity?
For example, consider this sentence with one two-word named entity:
>>> doc = nlp("This year was amazing.")
>>> doc.ents
(This year,)
>>> doc[0].ent_type_
'DATE'
>>> doc[1].ent_type_
'DATE'
Let's say we consider the first token ("This"), is it possible to retrieve the entity that its part of? Maybe something like this:
>>> doc[0].ents_
(This year,)
I guess that sometimes a token can be part of more than one entity.
At the moment, I'm obtaining this by creating a reverse dictionary from indices to entity indices.
Thanks!