Document length incorrect? Can't create span. #11325
-
I'm creating test data and faces into the issue with doc.char_span method, I start dig deeper and found interesting thing.
Lead to next errorIndexError Traceback (most recent call last) File ~/miniforge3/envs/mlp/lib/python3.9/site-packages/spacy/tokens/span.pyx:101, in spacy.tokens.span.Span.cinit() IndexError: [E035] Error creating span with start 0 and end 22 for Doc of length 6. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
When you create a span using the |
Beta Was this translation helpful? Give feedback.
-
@polm , thanks for the fast answer, yes my fault here.
it outputs address correct from first two print, but fails on creating span and output None 1616 Chapala St, Ste leads to :TypeError Traceback (most recent call last) File ~/miniforge3/envs/mlp/lib/python3.9/site-packages/spacy/tokens/doc.pyx:757, in spacy.tokens.doc.Doc.ents.set() File ~/miniforge3/envs/mlp/lib/python3.9/site-packages/spacy/tokens/doc.pyx:1926, in spacy.tokens.doc.get_entity_info() TypeError: object of type 'NoneType' has no len() |
Beta Was this translation helpful? Give feedback.
When you create a span using the
Span(...)
constructor, the indices are token indices, not character indices like inDoc.char_span
. This is why the Doc in your example is reported as having length 6.