From e7f8e13cf3740487e557beec52c26233847da9a9 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Mon, 16 Jan 2017 13:27:57 +0100 Subject: [PATCH] Make Token hashable. Fixes #743 --- spacy/tokens/token.pyx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spacy/tokens/token.pyx b/spacy/tokens/token.pyx index 6202677f0..fc84ba350 100644 --- a/spacy/tokens/token.pyx +++ b/spacy/tokens/token.pyx @@ -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