'spacy.tokens.token.Token' object has no attribute 'offset' #10338
-
First of all, many thanks for the wonderful library.This has been superuseful! What is a bit upsetting, though, that there is no universal support for start, end offsets among different span types. There is an explicit value of the start in the NER, but not in the token (one can apparently compute these from How to reproduce the behaviourDocumentation claims the token has an attribute
This will fail, but looking [at the code] the value of offset (https://github.com/explosion/spaCy/blob/master/spacy/tokens/token.pyx#L99) is written into attribute
It is very easy to fix, just save additionally (or instead) the value of offset to the attribute Your Environment
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Sorry this has been confusing. Tokens have token offsets in the You can find the list of attributes on the Token at the bottom of the page you linked to, which includes If that doesn't answer your question or I've misunderstood you let me know. |
Beta Was this translation helpful? Give feedback.
-
Hi @polm thank you very much for clarifying, I guess I haven't read docs very carefully. idx does work without a problem. |
Beta Was this translation helpful? Give feedback.
Sorry this has been confusing. Tokens have token offsets in the
i
attribute and character offsets in theidx
attribute; the token index is only referred to asoffset
(variable name) in the docs when it's an argument to the Token constructor. There is no guarantee that constructor arguments will have the same name when used as attributes.You can find the list of attributes on the Token at the bottom of the page you linked to, which includes
i
andidx
.If that doesn't answer your question or I've misunderstood you let me know.