Skip to content
This repository was archived by the owner on Feb 22, 2021. It is now read-only.

Commit 7762e86

Browse files
author
Philipp Dowling
committed
write header when converting model
1 parent 72c3d3d commit 7762e86

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

resources/gensim/convert_model.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
"""
2+
This can be used to convert gensim's output Word2Vec model to the two files we need in DBpedia Spotlight:
3+
the dictionary and the weights matrix.
4+
5+
They're saved in csv format, which can be read by Spotlight.
6+
"""
17
__author__ = 'dowling'
28

39
import sys
@@ -25,7 +31,7 @@ def convert_model(prefix):
2531

2632
ln.info("saving weights as csv...")
2733
weights_file = prefix+".syn0.csv"
28-
np.savetxt(weights_file, w2v.syn0, delimiter=",")
34+
np.savetxt(weights_file, w2v.syn0, delimiter=",", header="%sx%s" % w2v.syn0.shape)
2935

3036
ln.info("all done. Saved converted model files: %s and %s." % (weights_file, dict_file))
3137

0 commit comments

Comments
 (0)