Lexemes are unhashable (v0.101.0)
See original GitHub issueWhen I try to add Lexemes to a set or dict, it fails since Lexemes are unhashable:
cat = nlp.vocab['cat']
dog = nlp.vocab['dog']
my_animals = {cat, dog}
Traceback (most recent call last):
File "<ipython-input-30-8ffec97fae23>", line 1, in <module>
my_animals = {cat, dog}
TypeError: unhashable type: 'spacy.lexeme.Lexeme'
Maybe lexeme.orth can be used (together with lexeme.lang) as hash value?
Another funny observation is that looking up the same word multiple times through nlp.vocab[word]
produces Lexemes at different addresses (although comparison works thanks to the newly implemented rich comparison):
nlp.vocab['cat']
Out[17]: <spacy.lexeme.Lexeme at 0xe865401e10>
nlp.vocab['cat']
Out[18]: <spacy.lexeme.Lexeme at 0xe865401d80>
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
No results found
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Btw the line should probably be:
The old
.repvec
property is now named.vector
, too.The
__hash__
method will be there in the next release.@lylebrown Replace the curly braces ({ }) with square brackets ([ ]) in the following line: