Skip to content

Commit

Permalink
Make Token hashable. Fixes #743
Browse files Browse the repository at this point in the history
  • Loading branch information
honnibal committed Jan 16, 2017
1 parent 2c60d0c commit e7f8e13
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions spacy/tokens/token.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ cdef class Token:
self.c = &self.doc.c[offset]
self.i = offset

def __hash__(self):
return hash((self.doc, self.i))

def __len__(self):
'''Number of unicode characters in token.text'''
return self.c.lex.length
Expand Down

0 comments on commit e7f8e13

Please sign in to comment.