Skip to content

Conversation

hungvo304ml
Copy link

Using doc.spans["sc"] (SpanCategorizer) to solve the problem of overlapped tokens in nested NER for spacy. By replacing doc.ents with doc.spans["sc"], all possible entities are able to be stored without any errors.
After storing all possible spans, we filter out overlapping spans before adding them to doc.ents. Here we remove overlapping spans using spacy.util.filter_spans. When spans overlap, the rule is to prefer the first longest span over shorter ones.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant