【发布时间】:2020-09-19 22:35:11
【问题描述】:
我遇到了一个关于 nltk.corpus 和 wordnet 的小问题。它似乎找不到“是”的同义词,即使 thesaurus.com 说有,我如何才能提取我的“是”系统词以正确评估底部部分的输入。
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()
【问题讨论】: