mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-25 17:36:30 +03:00
Fix inconsistency of Vectors class API
This commit is contained in:
parent
94df115a81
commit
b2a8b9be77
|
@ -24,7 +24,12 @@ cdef class Vectors:
|
||||||
cdef public int i
|
cdef public int i
|
||||||
|
|
||||||
def __init__(self, strings, data_or_width=0):
|
def __init__(self, strings, data_or_width=0):
|
||||||
self.strings = StringStore()
|
if isinstance(strings, StringStore):
|
||||||
|
self.strings = strings
|
||||||
|
else:
|
||||||
|
self.strings = StringStore()
|
||||||
|
for string in strings:
|
||||||
|
self.strings.add(string)
|
||||||
if isinstance(data_or_width, int):
|
if isinstance(data_or_width, int):
|
||||||
self.data = data = numpy.zeros((len(strings), data_or_width),
|
self.data = data = numpy.zeros((len(strings), data_or_width),
|
||||||
dtype='f')
|
dtype='f')
|
||||||
|
@ -82,7 +87,8 @@ cdef class Vectors:
|
||||||
return i
|
return i
|
||||||
|
|
||||||
def items(self):
|
def items(self):
|
||||||
for i, string in enumerate(self.strings):
|
for i, key in enumerate(self.keys):
|
||||||
|
string = self.strings[key]
|
||||||
yield string, self.data[i]
|
yield string, self.data[i]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
Loading…
Reference in New Issue
Block a user