I am executing following lines of code. Vector file is produced using word2vec.
I am getting an error on this line:
vector = map(float, fields)
length_of_vectors = len(vector)
Error:
TypeError: object of type 'map' has no len()
How can i resolve this error?
I have tried converting
vector = map(float, fields)
to
vector = list(map(float, fields))
but it gives following error: ValueError: could not convert string to float
with io.open(vec_file, 'r', encoding="ISO-8859-1") as f:
for line in f:
line = line.strip()
if line == '':
continue
word = line[0:line.index(' ')]
rest = line[line.index(' ') + 1:]
fields = rest.split(' ')
vector = map(float, fields)
length_of_vectors = len(vector)
word_vector_dictionary[word] = vector
f.close()