加入收藏 | 设为首页 | 会员中心 | 我要投稿 云计算网_泰州站长网 (http://www.0523zz.com/)- 视觉智能、AI应用、CDN、行业物联网、智能数字人!
当前位置: 首页 > 服务器 > 搭建环境 > Unix > 正文

快来!建立你的第一个Python聊天机器人项目

发布时间:2020-03-02 12:14:24 所属栏目:Unix 来源:站长网
导读:副标题#e# 利用Python,我们可以实现很多目标,比如说建立一个你专属的聊天机器人程序。 聊天机器人程序不光满足个人需求,它对商业组织和客户都非常有帮助。大多数人喜欢直接通过聊天室交谈,而不是打电话给服务中心。 Facebook发布的数据证明了机器人的价

ChatBox.insert(END, "You: " + msg+ 'nn') 

ChatBox.config(foreground="#446665", font=("Verdana", 12 )) 

ints= predict_class(msg) 

res= getResponse(ints,intents) 

ChatBox.insert(END, "Bot: " + res+ 'nn') 

ChatBox.config(state=DISABLED) 

ChatBox.yview(END) 

root= Tk() 

root.title("Chatbot") 

root.geometry("400x500" 

root.resizable(width=FALSE, height=FALSE) 

#Create Chat window 

ChatBox= Text(root, bd=0, bg="white",height="8", width="50", font="Arial",) 

ChatBox.config(state=DISABLED) 

#Bind scrollbar to Chat window 

scrollbar= Scrollbar(root,command=ChatBox.yview, cursor="heart") 

ChatBox['yscrollcommand'] = scrollbar.set 

#Create Button to send message 

SendButton = Button(root,font=("Verdana",12,'bold'),text="Send", width="12", height=5, 

bd=0,bg="#f9a602",activebackground="#3c9d9b",fg='#000000', 

command=send ) 

#Create the box to enter message 

EntryBox= Text(root, bd=0, bg="white",width="29", height="5", font="Arial") 

#EntryBox.bind("<Return>",send) 

#Place all components on the screen 

scrollbar.place(x=376,y=6, height=386) 

ChatBox.place(x=6,y=6, height=386,width=370) 

EntryBox.place(x=128,y=401, height=90,width=265) 

SendButton.place(x=6,y=401, height=90) 

root.mainloop() 

运行聊天机器人

现在有两个独立的文件,一个是train_chatbot.py,首先使用它来训练模型。

pythontrain_chatbot.py 

(编辑:云计算网_泰州站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

推荐文章
    热点阅读