Prolog 中的聊天机器人 [英] Chatbot in Prolog
问题描述
我一直在尝试在 prolog 中创建一个聊天机器人(作为作业),到目前为止,我已经在 .pl 文件中创建了一个数据库,并列出了很多可能的对话.我知道 prolog 是这样工作的,例如,如果我们有
I've been trying to create a chatbot (as an assignment) in prolog, so far I have made a database in a .pl file and I have listed a lot of possible conversations. I know that prolog works like this for example if we have
Chatbot(good)
然后我们输入
?-Chatbot(good).
它会响应
yes or ture.
现在我不知道如何使用我的数据库,以便程序可以像聊天机器人一样工作,而无需编写适当的语法:
Now I don't know how to use my database so that the program can work exactly as a chatbot for example without the need to write in appropriate syntax:
Hello (typed by the user)
Hi there, (typed by the program automatically)
我的数据库是这样的:
answer( question, [
[Yes, I am here]]).
question ([are you there?])
推荐答案
原型 chatbot我知道是 ELIZA by Weizenbaum 1966.
The prototype chatbot I'm aware of is ELIZA by Weizenbaum 1966.
在 Prolog 中实现它相当容易,如 Sterling & 的 The Art of Prolog 所示.夏皮罗.
Implementing it in Prolog is rather easy, as shown in The Art of Prolog by Sterling & Shapiro.
谷歌搜索ELIZA Prolog",第一个链接给你一个相当复杂的实现,您可以在数据库中调整/重用引擎.但是这样你会失去所有的乐趣.我建议你阅读这本书并花时间实现你自己的.
Googling for 'ELIZA Prolog', the first link gives you a fairly complex implementation, and you could adapt/reuse the engine with your database. But this way you will lose all the fun. I suggest you read the book and take the time to implement your own.
这篇关于Prolog 中的聊天机器人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!