Skip to content

Fix relationship example entity offsets - #505

Open
mikemikimike wants to merge 1 commit into
explosion:mainfrom
mikemikimike:agent/fix-rel-entity-offsets
Open

Fix relationship example entity offsets#505
mikemikimike wants to merge 1 commit into
explosion:mainfrom
mikemikimike:agent/fix-rel-entity-offsets

Conversation

@mikemikimike

Copy link
Copy Markdown

Fixes #461

RELExample.to_doc() added spaces around punctuation before constructing the spaCy Doc, but matched entity offsets against the transformed token positions. When an entity boundary could not be found, the code created a span ending at -1, causing spaCy to raise an IndexError.

This change maps original text boundaries to the normalized Doc text and uses Doc.char_span() to construct entities. It also adds a regression test covering an entity after punctuation.

Validation:

  • pytest: 1 passed
  • ruff check: passed
  • python -m compileall -q spacy_llm

@mikemikimike
mikemikimike deleted the agent/fix-rel-entity-offsets branch August 2, 2026 02:16
@mikemikimike
mikemikimike restored the agent/fix-rel-entity-offsets branch August 2, 2026 11:22
@mikemikimike mikemikimike reopened this Aug 2, 2026
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.

Few-Shot Relationship Extraction Example Error

1 participant