Is is possible to add or modify attributes to Token after creating it

After v0.8.3, I noticed that the Token class now is a subclass of NamedTuple, which makes adding or modifying attributes after creating Token objects unachievable.
And it seems impossible to resolve the above issues by creating a specified MyToken class that inherits the Token objects( inheritance would not inference the type checking in other files) , because it still a subclass of NamedTuple.

Could you give a little more information about the context where you need to add or modify token attributes? It seems like a work-around here would depend on where in your pipeline you need to make these changes.

Thanks for the reply. I was about to add task specific tags for Token s (similar to pos/ner tags) to enrich the embeddings via the same pipeline provided by AllenNLP (tokenize, index, and embed).
However, my tags are obtained after the tokenize stage and before the index stage. It’s not a must, but I think it’s better to not break the predefined pipeline and do the least modifications.

If it’s before indexing, you should be safe just replacing them. Actually, I think even after indexing you might still be safe as long as the text_id attribute and/or text of the replaced tokens matches. ( I’m not sure if that holds up for ta

What did you mean “just replace them”? Can NamedTuples be changed after creating them?