使用aiml/lsh实现在线聊天机器人
2016-09-01 10:52
417 查看
你需要了解的相关知识,eliza(nltk实现的一个简单的聊天应用),aiml(人工智能标记语言),短文本相似性匹配,大部分在线的机器人基本都是通过question-anwser匹配的方式来实现人与机器之间的交互,目前来说效果并不好。本文实现的在线聊天机器人程序采用以下几种方式,aiml+短文件匹配+第三方调用。
实现思路:先定义aiml匹配的规则,准备qa样本数据通过lsh来生成模型,对于用户新输入的一个问题,优先从qa样本只匹配最相似的问题给出回答,如果没有则从aiml定义中寻找答案,如果还是没有,调用第三方的接口回答。
aiml配置文件如下:
在线聊天截图:
以上在线聊天机器人实现不是最优的,还有很多地方需要改进。
实现思路:先定义aiml匹配的规则,准备qa样本数据通过lsh来生成模型,对于用户新输入的一个问题,优先从qa样本只匹配最相似的问题给出回答,如果没有则从aiml定义中寻找答案,如果还是没有,调用第三方的接口回答。
aiml配置文件如下:
<?xml version="1.0" encoding="UTF-8"?> <aiml version="1.0"> <meta name="language" content="zh"/> <category> <pattern>* 再见</pattern> <template> <srai>BYE</srai> </template> </category> <category> <pattern>再见</pattern> <template> <srai>BYE</srai> </template> </category> <category> <pattern>BYE</pattern> <template> <random> <li>再见<get name="name"/>. </li> <li>再见啦,<get name="name"/>. </li> <li>下次见,<get name="name"/>. </li> <li>谢谢你陪我聊天,<get name="name"/>. </li> <li>改天见,<get name="name"/>. </li> </random> </template> </category> <category> <pattern>谢谢</pattern> <template> <random> <li>不客气.</li> <li>你太客气了.</li> </random> </template> </category> <category> <pattern>你好</pattern> <template> <srai>HELLO</srai> </template> </category> <category> <pattern>HELLO</pattern> <template> <random> <li>你好.</li> <li>你也好.</li> <li>你好啊.</li> </random> </template> </category> <category> <pattern>* 名字</pattern> <template> <srai>NAME</srai> </template> </category> <category> <pattern>NAME</pattern> <template> <random> <li>我是测试机器人.</li> <li>你可以叫我vs.</li> </random> </template> </category> <category> <pattern>* 几岁 *</pattern> <template> <srai>AGE</srai> </template> </category> <category> <pattern>AGE</pattern> <template> 我刚出生没有多久呢 </template> </category> <category> <pattern>* 什么问题 *</pattern> <template> <srai>EVERYTHING</srai> </template> </category> <category> <pattern>EVERYTHING</pattern> <template> just so so,不过你可以试一试,我擅长解决法律问题而已 </template> </category> <category> <pattern>* 目标 *</pattern> <template> <srai>TARGET</srai> </template> </category> <category> <pattern>TARGET</pattern> <template> 我有一个小目标,先看能不能赚个1个亿 </template> </category> </aiml>
在线聊天截图:
以上在线聊天机器人实现不是最优的,还有很多地方需要改进。
相关文章推荐
- 使用pb实现在线聊天!
- 使用图灵机器人API实现聊天机器人
- FMS3系列(六):使用远程共享对象(SharedObject)实现多人时时在线聊天(Flex | Flash)
- FMS3系列(六):使用远程共享对象(SharedObject)实现多人时时在线聊天(Flex | Flash) 推荐
- 使用socket与线程实现简单机器人聊天
- Python进阶开发之网络编程,socket实现在线聊天机器人
- java在线聊天项目0.3版本 制作客户端窗体,实现发送按钮和回车发送信息功能,使用ActionListener监听事件中actionPerformed方法(用内部类和匿名内部类两种方法)
- FMS3系列(六):使用远程共享对象(SharedObject)实现多人时时在线聊天(Flex | Flash)
- java在线聊天项目1.1版 ——开启多个客户端,分别实现注册和登录功能,使用客户端与服务端信息request机制,重构线程,将单独的登录和注册线程合并
- FMS3系列(六):使用远程共享对象(SharedObject)实现多人时时在线聊天(Flex | Flash)
- 使用远程共享对象(SharedObject)实现多人时时在线聊天(Flex | Flash)
- FMS3系列(六):使用远程共享对象(SharedObject)实现多人时时在线聊天(Flex | Flash)
- Java中使用websocket实现在线聊天功能
- Python使用django框架实现多人在线匿名聊天的小程序
- FMS3系列(六):使用远程共享对象(SharedObject)实现多人时时在线聊天(Flex | Flash)
- 使用websocket实现在线聊天功能
- FMS3系列(六):使用远程共享对象(SharedObject)实现多人时时在线聊天(Flex | Flash)
- 使用UDP实现内部聊天举例
- ArcGIS.Server.9.2.DotNet实现在线编辑EditorTask使用(自带例子 十、二)
- 使用DSO实现在线WORD文档编辑