Skip to content

Commit

Permalink
fixed a bug related to writing the word vector to the file
Browse files Browse the repository at this point in the history
  • Loading branch information
hardikp committed May 2, 2017
1 parent e0fa410 commit a0ed5dc
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 4 deletions.
2 changes: 1 addition & 1 deletion glove.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def train_glove(args):
j = Variable(torch.LongTensor([i]))
vec = (model.l_vecs(j) + model.r_vecs(j)).data.squeeze()
for k in range(vec.size(0)):
s + ' ' + str(vec[k])
s += ' ' + str(round(vec[k], 6))

f.write(s)

Expand Down
6 changes: 3 additions & 3 deletions test_word_vectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


def print_nearest_words(args):
word = args.word.lower()
word = args.word.lower().strip()

# Load the word vectors
embeddings_index = {}
Expand All @@ -19,8 +19,8 @@ def print_nearest_words(args):
embeddings_index[w] = coefs
f.close()

w_v = np.zeros(50)
for w in word.strip().split():
w_v = np.zeros_like(embeddings_index[w])
for w in word.split():
if w not in embeddings_index.keys():
continue

Expand Down
Loading

0 comments on commit a0ed5dc

Please sign in to comment.