mirror of https://github.com/explosion/spaCy.git
Make change to Vectors.__init__
This commit is contained in:
parent
ebecaddb76
commit
cfae54c507
|
@ -32,7 +32,7 @@ cdef class Vectors:
|
||||||
cdef public object keys
|
cdef public object keys
|
||||||
cdef public int i
|
cdef public int i
|
||||||
|
|
||||||
def __init__(self, strings, data=None, width=0):
|
def __init__(self, strings, width=0, data=None):
|
||||||
if isinstance(strings, StringStore):
|
if isinstance(strings, StringStore):
|
||||||
self.strings = strings
|
self.strings = strings
|
||||||
else:
|
else:
|
||||||
|
@ -46,6 +46,10 @@ cdef class Vectors:
|
||||||
self.i = 0
|
self.i = 0
|
||||||
self.key2row = {}
|
self.key2row = {}
|
||||||
self.keys = numpy.zeros((self.data.shape[0],), dtype='uint64')
|
self.keys = numpy.zeros((self.data.shape[0],), dtype='uint64')
|
||||||
|
for i, string in enumerate(self.strings):
|
||||||
|
if i >= self.data.shape[0]:
|
||||||
|
break
|
||||||
|
self.add(self.strings[string], self.data[i])
|
||||||
|
|
||||||
def __reduce__(self):
|
def __reduce__(self):
|
||||||
return (Vectors, (self.strings, self.data))
|
return (Vectors, (self.strings, self.data))
|
||||||
|
|
Loading…
Reference in New Issue