From 86eba61fae69827df0571eddcf754a2954c81358 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Wed, 1 Nov 2017 00:47:35 +0100 Subject: [PATCH] Fix token.vector when vectors are missing --- spacy/tests/spans/test_span.py | 3 +-- spacy/tokens/token.pyx | 5 +---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/spacy/tests/spans/test_span.py b/spacy/tests/spans/test_span.py index 4050809b5..b8638ba4b 100644 --- a/spacy/tests/spans/test_span.py +++ b/spacy/tests/spans/test_span.py @@ -118,8 +118,7 @@ def test_span_to_array(doc): assert arr[0, 1] == len(span[0]) -@pytest.mark.xfail def test_span_as_doc(doc): span = doc[4:10] span_doc = span.as_doc() - assert span.text == span_doc.text + assert span.text == span_doc.text.strip() diff --git a/spacy/tokens/token.pyx b/spacy/tokens/token.pyx index fa07d0e9e..c3d92b389 100644 --- a/spacy/tokens/token.pyx +++ b/spacy/tokens/token.pyx @@ -302,10 +302,7 @@ cdef class Token: def __get__(self): if 'vector' in self.doc.user_token_hooks: return self.doc.user_token_hooks['vector'](self) - if self.has_vector: - return self.vocab.get_vector(self.c.lex.orth) - else: - return self.doc.tensor[self.i] + return self.vocab.get_vector(self.c.lex.orth) property vector_norm: """The L2 norm of the token's vector representation.