Best way to refer from one entity span to another? #10825
-
Given an entity Span object from Doc.ents, what's the best way to make a reference to another entity span for describing relationships between entities? My first inclination is to just declare an extension, and assign a span to it. But, the entity span objects are ephemeral, and it feels like doing it that way isn't correct. Is there a better way to store relationships between entity spans? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
It's true Spans are ephemeral, but they're tied to the Doc they come from, so I don't think putting a Span under its parent Doc should be a problem. That's the strategy used in the relation extraction component, which uses a
You can also use |
Beta Was this translation helpful? Give feedback.
It's true Spans are ephemeral, but they're tied to the Doc they come from, so I don't think putting a Span under its parent Doc should be a problem. That's the strategy used in the relation extraction component, which uses a
doc._.rel
extension, so for the relationA eats B
you would have something like:You can also use
doc.spans
for this purpose. The Spans in a SpanGroup are ordered so you can convey a relationship that way, though I think the extension might be clearer.