所以我用这个代码来获取同义词
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
现在,如果我使用Get_Syn('recieve')
,我会收到一个空列表(没有同义词)。但是,如果我使用
Get_Syn('get')
,这是我得到的列表:
[{'get': 'acquire'},
{'get': 'become'},
{'get': 'go'},
{'get': 'let'},
{'get': 'have'},
{'get': 'receive'},
{'get': 'find'},
{'get': 'obtain'},
.
.
.
]
正如我们所看到的,recieve
是get
的同义词,但get
不是recieve
的同义词
那么,当我搜索recieve
时,如何获得get
。有没有办法把两者联系起来
你的功能是正确的。 您有vocab错误,无法写入接收。 收信人错了,请再核对一下你的话
相关问题 更多 >
编程相关推荐