mirror of https://github.com/explosion/spaCy.git
Fix Doc.vector for empty doc objects
This commit is contained in:
parent
0551b7b03a
commit
03b5b9727a
|
@ -303,7 +303,10 @@ cdef class Doc:
|
|||
return self.user_hooks['vector'](self)
|
||||
if self._vector is not None:
|
||||
return self._vector
|
||||
elif self.has_vector and len(self):
|
||||
elif not len(self):
|
||||
self._vector = numpy.zeros((self.vocab.vectors_length,), dtype='f')
|
||||
return self._vector
|
||||
elif self.has_vector:
|
||||
vector = numpy.zeros((self.vocab.vectors_length,), dtype='f')
|
||||
for token in self.c[:self.length]:
|
||||
vector += self.vocab.get_vector(token.lex.orth)
|
||||
|
|
Loading…
Reference in New Issue