我和nltk.corpus和wordnet有个小问题。它似乎找不到'yes‘的同义词,即使thesaurus.com说有,我如何才能提取我的'yes’sysnoyms,以便正确地评估输入到底部。
import textblob as txtnlp
from nltk.corpus import wordnet
def text_extraction():
yes_ls = []
for synset in wordnet.synsets("yes"):
for lemma in synset.lemmas():
yes_ls.append(lemma.name())
init_conversation = str(input('Hello there my name is Therpibot 2.0, your name is? '))
blob_1 = txtnlp.TextBlob(init_conversation)
fragments_name = blob_1.words
print(f'Hello there {fragments_name[0]}!', end=' ')
print('My purpose is to make your day better through some cognitive behavioral therapy.')
init_response = str(input('Would like to engage in a talk session? '))
if init_response.lower() in yes_ls:
therapy()
#ex_1 = list(i.tags for i in fragments)
#print(ex_1)
def therapy():
print('Hi')
if __name__ in "__main__":
text_extraction()发布于 2020-09-20 07:27:01
我以前也尝试过这样做,但是wordnet不是我最好的选择,但是你可以看看这里:Wordnet Find Synonyms
我向你推荐http://www.conceptnet.io/,它对你的任务来说更好更容易,它是一个开放的数据集,你可以免费访问它
https://stackoverflow.com/questions/63973959
复制相似问题