File tree 3 files changed +104
-4
lines changed
3 files changed +104
-4
lines changed Original file line number Diff line number Diff line change @@ -86,7 +86,7 @@ def train_glove(args):
86
86
j = Variable (torch .LongTensor ([i ]))
87
87
vec = (model .l_vecs (j ) + model .r_vecs (j )).data .squeeze ()
88
88
for k in range (vec .size (0 )):
89
- s + ' ' + str (vec [k ])
89
+ s += ' ' + str (round ( vec [k ], 6 ) )
90
90
91
91
f .write (s )
92
92
Original file line number Diff line number Diff line change 7
7
8
8
9
9
def print_nearest_words (args ):
10
- word = args .word .lower ()
10
+ word = args .word .lower (). strip ()
11
11
12
12
# Load the word vectors
13
13
embeddings_index = {}
@@ -19,8 +19,8 @@ def print_nearest_words(args):
19
19
embeddings_index [w ] = coefs
20
20
f .close ()
21
21
22
- w_v = np .zeros ( 50 )
23
- for w in word .strip (). split ():
22
+ w_v = np .zeros_like ( embeddings_index [ w ] )
23
+ for w in word .split ():
24
24
if w not in embeddings_index .keys ():
25
25
continue
26
26
You can’t perform that action at this time.
0 commit comments