mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-25 01:16:28 +03:00
Make Token hashable. Fixes #743
This commit is contained in:
parent
2c60d0cb1e
commit
e7f8e13cf3
|
@ -42,6 +42,9 @@ cdef class Token:
|
||||||
self.c = &self.doc.c[offset]
|
self.c = &self.doc.c[offset]
|
||||||
self.i = offset
|
self.i = offset
|
||||||
|
|
||||||
|
def __hash__(self):
|
||||||
|
return hash((self.doc, self.i))
|
||||||
|
|
||||||
def __len__(self):
|
def __len__(self):
|
||||||
'''Number of unicode characters in token.text'''
|
'''Number of unicode characters in token.text'''
|
||||||
return self.c.lex.length
|
return self.c.lex.length
|
||||||
|
|
Loading…
Reference in New Issue
Block a user