原创地址http://www.codeproject.com/Articles/36106/Chatbot-Tutorial#intro
为了提高英语水平坚持 没事的时候 翻译一下这篇文章。
今天 先简单的 翻译一下第一部分。本人英语超级菜,所以请各位看原始英文版,以免误导各位,每天翻译多少就上传多少。
制作一个人工智能聊天机器人教程
一步一步的指导你如何制作你自己的聊天机器人
1:Introduction Chatbot Description (first example)
简介聊天机器人 第一个例子
Basically a chatterbot is a computer program that when you provide it with some inputs in Natural Language (English, French ...) responds with something meaningful in that same language. Which means that the strength of a chatterbot could be directly measured by the quality of the output selected by the Bot in response to the user. By the previous description, we could deduce that a very basic chatterbot can be written in a few lines of code in a given specific programming language. Lets make our first chatterbot (notice that all the codes that will be used in this tutorial will be written in C++. Also, it is assumed that the reader is familiar with the STL library) This tutorial is also available in the following languages: Java, Visual Basic, C#, Pascal, Prolog and Lisp
基本上一个聊天机器人程序就是当你用自然语言(英语,法语....)提供输入时,它能够用相同的语言做出有意义的应答。
意思是一个健壮的聊天机器人可以的在响应用户时直接判断输出。通过前面的描述,我们可以推断一个非常基础的聊天机器人可以是用一种特定的编程语言写几行代码来完成的。
让我们编写第一个聊天机器人吧(注意:本教程的所有代码全部用C++,并且假定读者已经熟悉STL)。这个教程也可用如下语言编写 :
java vb c# pascal(DELPHI) and Lisp
1 // 2 // Program Name: chatterbot1 3 // Description: this is a very basic example of a chatterbot program 4 // 5 // Author: Gonzales Cenelia 6 // 7 8 #include <iostream> 9 #include <string> 10 #include <ctime> 11 12 int main() 13 { 14 std::string Response[] = { 15 "I HEARD YOU!", 16 "SO, YOU ARE TALKING TO ME.", 17 "CONTINUE, I’M LISTENING.", 18 "VERY INTERESTING CONVERSATION.", 19 "TELL ME MORE..." 20 }; 21 22 srand((unsigned) time(NULL)); 23 24 std::string sInput = ""; 25 std::string sResponse = ""; 26 27 while(1) { 28 std::cout << ">"; 29 std::getline(std::cin, sInput); 30 int nSelection = rand() % 5; 31 sResponse = Response[nSelection]; 32 std::cout << sResponse << std::endl; 33 } 34 35 return 0; 36 }
As you can see, it doesn't take a lot of code to write a very basic program that can interact with a user but it would probably be very difficult to write a program that would really be capable of truly interpreting(说明) what the user is actually saying and after that would also gene
rate an appropriate response to it. These have been a long term goal since the beginning and even before the very first computers were created. In 1951,the British mathematician(数学家)Alan Turing has came up with the question Can machines think and he has also propose a test which is now known as the Turing Test.In this test, a computer program and also a real person is set to speak to a third person (the judge) and he has to decide which of them is the real person. Nowadays, there is a competition that was named the Loebner Prize and in this competition bots that has successfully fool most of the judge for at list 5 minutes would win a prize of 100.000$. So far no computer program was able to pass this test successfully. One of the major reasons for this is that computer programs written to compute in such contest have naturally the tendency(倾向) of committing a lot oftypo(排印错误) (they are often out of the context of the conversation). Which means that generally, it isn't that difficult for a judge to decide whether he is speaking to a "computer program" or a real person. Also, the direct ancestor of all those program that tries to mimic(模仿) a conversation between real human beings is Eliza,the first version of this program was written in 1966 by Joseph Weizenbaum a professor of MIT.
正如你看到的,他不需要很多的代码去编写一个非常基础的项目,它和用户交互,但是编写一个能够真正理解用户实际所说的话并给出适当的应答的程序是很难的。
甚至从第一台电脑诞生以来,这就一直是一个长期目标。
在1951年,英国数学家 阿兰 图灵提出一个问题 “机器人可以思考”并且提出了一个测试,现在被称为“图灵测试”,
在这个测试中 一个电脑程序和是一个真人,将和第三个人对话。第三个人要分辨出哪个是真人。
如今,有一个被叫做“勒布纳奖"的竞赛。在这个竞赛机器人如果欺骗了大多数”裁判官“将得到10W美金。目前为止还没有任何程序通过测试。
主要原因是,为这个项目写一个有语言倾向的估算有很多错误(他们经常断章取义的交谈)。
意思就是说,区分机器人和真人并不是很难的。
1 Interact v. 互相作用; 互动; 互相影响 2 probably adv. 大概, 或许 3 capable adj. 有能力的, 能干的, 能的 4 truly adv 真实的 不假的 5 interpretive adj. 作为说明的; 解释的 6 actually adv. 实际上, 真的; 竟然 7 generate v. 产生, 导致, 发生 8 appropriate v. 拨出; 挪用, 盗用; 占用 9 adj. 适当的, 恰当的, 相称的 10 term goal 长期目标 11 propose v. 计划, 建议, 打算; 打算, 求婚 12 judge n. 法官, 推事, 审判官 13 v. 审理; 判断; 鉴定; 下判断; 作评价 14 major n. 主修, 陆军少校, 成年人; 大调 15 v. 主修 16 adj. 主要的, 大部份的, 较多的; 主修的, 大调的, 成年的 17 reason n. 理由, 动机, 原因; 判断力, 推理; 理性, 理智; 道理, 情理 18 v. 推论, 思考, 劝说; 说服, 辩论, 推论 19 compute v. 计算; 推断; 估算 20 contest n. 竞赛, 争论 21 v. 竞赛, 争辩, 争取; 争夺 22 tendency n. 趋向, 倾向 23 conversation n. 会话, 交谈, 说话 24 generally adv. 通常, 普遍地, 逐渐地; 一般来说 25 direct v. 指示, 命令, 指挥; 指导; 指挥 26 adj. 直接的, 坦白的 27 adv. 直接地 28 ancestor n. 祖宗, 祖先; 先驱; 原型; 被继承人 29 tries n. 试验者, 审问者, 试验物 30 mimic n. 效颦者; 小丑; 模仿者 31 v. 模仿; 摹拟 32 adj. 模仿的; 拟态的; 假装的 33 conversation n. 会话, 交谈, 说话 34 considered adj. 考虑过的; 被尊重的 35 belong v. 属于, 住; 合适; 适宜 36 weak adj. 不牢固的, 虚弱的, 弱的 37 field n. 领域, 范围, 领地; 场地, 田地; 被指定为记录里信息项目的空间 (计算机用语); 表面; 用于运动的场地; 游戏者的作品; 层次; 打仗的场地, 战场; 战斗 38 v. 使上场; 担任场外队员 39 adj. 田间的; 野外的; 野生的 40 artificial adj. 人工的, 人造的; 矫揉造作的, 不自然的; 假的; 人为的 41 intelligence n. 智力; 智能; 聪明 42 opposed adj. 反对的, 对抗的, 敌对的 43 potential n. 潜在性, 可能性 44 adj. 有潜力的, 潜在的, 可能的 45 communicate vt. 传达,表达;显示:清晰地揭示;表明;传染:扩散; 46 vi. 通讯;交际;相连;相通; 47 advance n. 前进; 增长; 发展; 增高 48 v. 使向前移动; 将...提前; 推进, 促进; 预付; 前进; 进展; 向前移动; 进步 49 adj. 先行的; 预先的, 事先的 50 accessible adj. 易受影响的, 易接近的, 可进入的 51 hobbyist n.沉溺于某种癖好者, 业余爱好者