微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

为什么按钮不能显示数据,在运行时按钮显示出来,但是单击时没有作用

如何解决为什么按钮不能显示数据,在运行时按钮显示出来,但是单击时没有作用

import nltk
from nltk.chat.util import Chat,reflections
import pandas as pd
import ipywidgets as widgets
from ipywidgets import interact,interact_manual,fixed

df = pd.read_excel (r'C:\Users\Desktop\ex\ex_dataset.xlsx',sheet_name='Sheet3')

print ('Travel Suggestion')

pairs=[
   ['My name is (.*)',['hi %1']],['What is Travel Suggestion',['Travel Suggestion is suggest the best of Restaurant or Tourist attraction']],]

widgets.interact_manual.opts['manual_name'] = 'Restaurant'
def Restaurant():
    print(df)
    
interact_manual(Restaurant)
chat = Chat(pairs,reflections)
chat.converse()

解决方法

chat.converse()运行时,您无法在笔记本中运行其他任何东西。

这是一种适合您需求的解决方法:

单元格[1]

import nltk
from nltk.chat.util import Chat,reflections
import pandas as pd
import ipywidgets as widgets
from ipywidgets import interact,interact_manual,fixed

df = pd.read_excel (r'C:\Users\Desktop\ex\ex_dataset.xlsx',sheet_name='Sheet3')

print ('Travel Suggestion')

pairs=[
   ['My name is (.*)',['hi %1']],['What is Travel Suggestion',['Travel Suggestion is suggest the best of Restaurant or Tourist attraction']],]

widgets.interact_manual.opts['manual_name'] = 'Restaurant'
def Restaurant():
    print(df)
    
interact_manual(Restaurant)
chat = Chat(pairs,reflections)

单元格[2]

chat.converse()

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。