问题描述
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()