Skip to content

Commit e0fa410

Browse files
committed
Minor change in the test script
1 parent fda36c7 commit e0fa410

File tree

2 files changed

+7
-17
lines changed

2 files changed

+7
-17
lines changed

README.md

+3-15
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,13 @@ Let's check if the closest words make sense.
2424

2525
```bash
2626
$ python3 test_word_vectors.py --word IRA
27-
Roth
28-
SEP
29-
IRAs
30-
401
31-
retirement
27+
roth, iras, sep, 401, contribute
3228

3329
$ python3 test_word_vectors.py --word option
34-
call
35-
put
36-
options
37-
exercise
38-
underlying
30+
call, options, put, exercise, underlying
3931

4032
$ python3 test_word_vectors.py --word stock
41-
shares
42-
market
43-
stocks
44-
share
45-
price
33+
shares, share, market, stocks, price
4634
```
4735

4836
## Notes

test_word_vectors.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88

99
def print_nearest_words(args):
10+
word = args.word.lower()
11+
1012
# Load the word vectors
1113
embeddings_index = {}
1214
f = open(args.vectors)
@@ -18,7 +20,7 @@ def print_nearest_words(args):
1820
f.close()
1921

2022
w_v = np.zeros(50)
21-
for w in args.word.strip().split():
23+
for w in word.strip().split():
2224
if w not in embeddings_index.keys():
2325
continue
2426

@@ -27,7 +29,7 @@ def print_nearest_words(args):
2729
# Get the similarity scores
2830
score_dict = {}
2931
for w in embeddings_index.keys():
30-
if args.word == w:
32+
if word == w:
3133
continue
3234

3335
score = cosine_similarity(w_v.reshape(1, -1), embeddings_index[w].reshape(1, -1))[0][0]

0 commit comments

Comments
 (0)