简体   繁体   English

NLTK.corpus 和 wordnet

[英]NLTK.corpus and wordnet

I am having a minor issue with nltk.corpus and wordnet.我对 nltk.corpus 和 wordnet 有一个小问题。 It can't seem to find synonyms for 'yes', even though thesaurus.com says there is, how I can I extract my 'yes' sysnoyms in order to properly assess input into that bottom section.它似乎无法找到“是”的同义词,即使 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()

i've tried to do something like that before but wordnet wasn't my best choice but you can take a look here: Wordnet Find Synonyms我以前尝试过做类似的事情,但 wordnet 不是我的最佳选择,但您可以在这里查看: Wordnet Find Synonyms

and i recommend http://www.conceptnet.io/ for you , it's much better and easier for your task , it's an open data set you can access it for free我为你推荐http://www.conceptnet.io/ ,它对你的任务来说更好更容易,它是一个开放的数据集,你可以免费访问它

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM