18 lines
448 B
Python
Executable File
18 lines
448 B
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
import gzip
|
|
import numpy
|
|
import pickle
|
|
|
|
vectors = {}
|
|
with gzip.open("numberbatch-en-19.08.txt.gz", mode="rt") as f:
|
|
count = int(next(f).split()[0])
|
|
for (i, line) in enumerate(f):
|
|
if i % 1000 == 0:
|
|
print("{}/{}".format(i, count))
|
|
[word, *vec] = line.split()
|
|
vectors[word] = numpy.array([float(x) for x in vec])
|
|
|
|
with open('numberbatch.pkl', 'wb') as f:
|
|
pickle.dump(vectors, f)
|