From f18805ee1c4c37632cc5cfbc369223cb1fdd4641 Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Thu, 24 Mar 2016 15:40:12 +0100 Subject: [PATCH] make StringStore.__contains__() return True for the empty string (which is also contained in iteration) --- spacy/strings.pyx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spacy/strings.pyx b/spacy/strings.pyx index aa1f5c92d..c890cdd22 100644 --- a/spacy/strings.pyx +++ b/spacy/strings.pyx @@ -116,7 +116,9 @@ cdef class StringStore: else: raise TypeError(type(string_or_id)) - def __contains__(self, unicode string): + def __contains__(self, unicode string not None): + if len(string) == 0: + return True cdef hash_t key = hash_string(string) return self._map.get(key) is not NULL