So I am using this code to get the synonyms.
from nltk.corpus import wordnet
def Get_Syn(text):
xx = []
sentence1 = text.split(" ")
for i in sentence1:
if i not in stopwords:
for syn in wordnet.synsets(i):
for name in syn.lemma_names():
if name != i.lower():
xx.append({i:name})
else:
pass
return xx
Now, if I use Get_Syn('recieve')
, I recieve an empty list (no synonyms). But, if I use
Get_Syn('get')
, this is the list I get:
[{'get': 'acquire'},
{'get': 'become'},
{'get': 'go'},
{'get': 'let'},
{'get': 'have'},
{'get': 'receive'},
{'get': 'find'},
{'get': 'obtain'},
.
.
.
]
As we see, recieve
is a synonym of get
, but get
is not a synonym of recieve
.
So how can I get get
when I search for recieve
. Is there way to map the two together?
your function is right. you have vocab error to write receive. recieve is wrong please check your word again.
Get_Syn('receive')
[
{'receive': 'have'},
{'receive': 'get'}, <===
{'receive': 'find'},
{'receive': 'obtain'},
...