Overlapping Named Entities & pattern approach #10096
-
Hey, Custom Pipeline Component:
Sample Input data:
Expected Entities:1st Entity (ent.text, ent.label_): Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hello ✨, For your usecase it could look like this:
|
Beta Was this translation helpful? Give feedback.
-
Also note we're working on a SpanRuler which should do exactly what you want, though it might not be released for a while yet. |
Beta Was this translation helpful? Give feedback.
Hello ✨,
you can save the spans inside
doc.spans
instead ofdoc.ents
, giving you the possibility to have overlapping spans. (https://spacy.io/api/doc#spans)For your usecase it could look like this:
doc.spans
is a dictionary of SpanGroups which is a container for Span objects, instead of the key "Match", used in the example above, you can choose whatever key you seem fit. 😄 Since your use case works with a rule based approach, there is no need to implement the SpanCategorizer pipeline inside your function