Issue
I have the below code which is trying to find similar words between the two lists. For this purpose I am using spacy's .similarity function.
import en_vectors_web_lg
nlp = en_vectors_web_lg.load()
listx =['HSBC', 'JP Morgan',......] #500 words lists
listy = ['Currency','Blockchain'.......] #1000 words lists
s_words = []
for token1 in listy:
list_to_sort = []
for token2 in listx:
list_to_sort.append((token1, token2,nlp(str(token1)).similarity(nlp(str(token2)))))
sorted_list = sorted(list_to_sort, key = itemgetter(2), reverse=True)[0][:2]
s_words.append(sorted_list)
On running the above code I keep getting the warning: UserWarning: [W008] Evaluating Doc.similarity based on empty vectors"
I came across solutions like setting an environment variable "SPACY_WARNING_IGNORE=W008" to suppress the error "UserWarning: [W008] Evaluating Doc.similarity based on empty vectors"
My question is where and how to set up this environment variable?
I am using windows 10, Spyder IDE, Python 3.7 and Spacy 2.2.5.
Solution
You need to add the following lines to your code to set that environment variable:
import os
os.environ['SPACY_WARNING_IGNORE'] = 'W008'
Answered By - Carlos Cordoba
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.