首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >NLTK.corpus和wordnet

NLTK.corpus和wordnet
EN

Stack Overflow用户
提问于 2020-09-20 06:35:11
回答 1查看 52关注 0票数 1

我和nltk.corpus和wordnet有个小问题。它似乎找不到'yes‘的同义词,即使thesaurus.com说有,我如何才能提取我的'yes’sysnoyms,以便正确地评估输入到底部。

代码语言:javascript
复制
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()
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-09-20 07:27:01

我以前也尝试过这样做,但是wordnet不是我最好的选择,但是你可以看看这里:Wordnet Find Synonyms

我向你推荐http://www.conceptnet.io/,它对你的任务来说更好更容易,它是一个开放的数据集,你可以免费访问它

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63973959

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档