diff --git a/README.md b/README.md index 1f55999..695e76d 100644 --- a/README.md +++ b/README.md @@ -24,25 +24,13 @@ Let's check if the closest words make sense. ```bash $ python3 test_word_vectors.py --word IRA -Roth -SEP -IRAs -401 -retirement +roth, iras, sep, 401, contribute $ python3 test_word_vectors.py --word option -call -put -options -exercise -underlying +call, options, put, exercise, underlying $ python3 test_word_vectors.py --word stock -shares -market -stocks -share -price +shares, share, market, stocks, price ``` ## Notes diff --git a/test_word_vectors.py b/test_word_vectors.py index 05f77a9..a875c18 100644 --- a/test_word_vectors.py +++ b/test_word_vectors.py @@ -7,6 +7,8 @@ def print_nearest_words(args): + word = args.word.lower() + # Load the word vectors embeddings_index = {} f = open(args.vectors) @@ -18,7 +20,7 @@ def print_nearest_words(args): f.close() w_v = np.zeros(50) - for w in args.word.strip().split(): + for w in word.strip().split(): if w not in embeddings_index.keys(): continue @@ -27,7 +29,7 @@ def print_nearest_words(args): # Get the similarity scores score_dict = {} for w in embeddings_index.keys(): - if args.word == w: + if word == w: continue score = cosine_similarity(w_v.reshape(1, -1), embeddings_index[w].reshape(1, -1))[0][0]