当前位置: 首页 > 编程日记 > 正文

chatscript_如何使用ChatScript构建您的第一个聊天机器人

chatscript

by Giorgio Robino

通过乔治·罗宾诺(Giorgio Robino)

如何使用ChatScript构建您的第一个聊天机器人 (How to build your first chatbot using ChatScript)

10–10–2018: article updated with new github repo url.

2018年10月10日:文章更新为新的github repo url 。

Chatbots can help you get things done right inside chat tools like Facebook Messenger, Telegram Messenger, Slack, etc, etc. Just say the word and your chatbot will deploy your latest build, or order you a pizza.

聊天机器人可以帮助您在诸如Facebook Messenger,Telegram Messenger,Slack等聊天工具中完成工作。只需说出单词,您的聊天机器人就会部署您的最新版本,或为您订购披萨。

And there’s a special tool for building chatbots that’s been around for quite some time. It’s called ChatScript. And like Slack, it started out as just a small part of a video game.

还有一个用于构建聊天机器人的特殊工具已经存在了很长时间。 它称为ChatScript。 和Slack一样,它最初只是视频游戏的一小部分。

Back in 2009, Bruce Wilcox was working as a game developer and artificial intelligence researcher. His wife, Sue Wilcox, wanted to model virtual characters for her interactive fiction games. Together, they built what ultimately became ChatScript.

早在2009年, 布鲁斯·威尔科克斯 ( Bruce Wilcox )担任游戏开发人员和人工智能研究员。 他的妻子苏·威尔科克斯 ( Sue Wilcox )希望为她的互动小说游戏建模虚拟角色。 他们一起建立了最终成为ChatScript的文件。

This natural language processing engine + dialog flow scripting platform helped Bruce win the Loebner AI Prize three times.

这个自然语言处理引擎+对话流程脚本平台帮助布鲁斯三度获得了Loebner AI奖 。

Bruce still develops and maintains the project today. It’s written in C and C++, and is open source. In fact, version 6.8 just came out a few weeks ago.

布鲁斯今天仍在开发和维护该项目。 它是用C和C ++编写的,并且是开源的。 实际上,6.8版本是几周前发布的。

ChatScript is one of few OPENSOURCE chatbots NLProc engines!

ChatScript是少数OPENSOURCE聊天机器人NLProc引擎之一!

Let’s dive into the basics of ChatScript and meet a chatbot named Harry.

让我们深入探讨ChatScript的基础知识,并遇到一个名为Harry的聊天机器人。

安装ChatScript (Installing ChatScript)

Some of these steps may be a bit different depending on what operating system you’re using. I’m using Linux. You don’t actually have to go through these steps to enjoy this article if you don’t want to. Just read along.

其中某些步骤可能会有所不同,具体取决于您所使用的操作系统。 我正在使用Linux 。 如果不想,您实际上不必执行这些步骤即可享受本文的乐趣。 只是阅读。

步骤1:在本地计算机上安装系统组件 (Step 1: Install the system components on your local computer)

First of all clone the ChatScript GitHub repository:

首先克隆ChatScript GitHub存储库:

$ git clone https://github.com/ChatScript/ChatScript

This will create a ChatScript directory, which will contain these subdirectories:

这将创建一个ChatScript目录,其中将包含以下子目录:

$ cd ChatScript/$ ls -d1 */
BINARIES/DICT/DOCUMENTATION/LINUX/LIVEDATA/LOEBNERVS2010/LOGS/MAC/RAWDATA/REGRESS/SERVER BATCH FILES/SRC/SUBLIME TEXT EDITOR/TMP/TOPIC/USERS/VERIFY/VS2010/VS2015/WEBINTERFACE/
  • DOCUMENTATION contains wiki documentation files.

    文档包含Wiki文档文件 。

BTW, I personally contributed to update all the original documentation in markdown format to be read online and from command line when developing.❤

顺便说一句,我个人致力于以markdown格式更新所有原始文档,以便在开发时从命令行和命令行读取。

  • RAWDATA contains a subdirectory for each bot. By default, the platform comes with a default bot named Harry, who is located at RAWDATA/HARRY.

    RAWDATA包含每个bot的子目录。 默认情况下,该平台附带一个名为Harry的默认bot,该机器人位于RAWDATA / HARRY。

BTW, please remember to set LinuxChatScript64 executable:

顺便说一句,请记住设置LinuxChatScript64可执行文件:

$ chmod +x ChatScript/BINARIES/LinuxChatScript64

Note: obviously here above I’ considering the Linux OS environment.

注意:显然,在上面我在考虑Linux OS环境。

More info about Linux, MacOS or Windows installation here.

有关Linux,MacOS或Windows安装的更多信息,请参见此处 。

步骤2:以独立模式运行CS引擎: (Step 2: To run CS engine in standalone mode:)

$ BINARIES/LinuxChatScript64 local

Running the engine will launch Harry, with whom we can then talk:

运行引擎将启动Harry,然后我们可以与他交谈:

ChatScript EVSERVER Version 6.8  64 bit LINUX compiled Aug 16 2016 17:35:43 host=localParams:   dict:720895 fact:800000 text:70000kb hash:50000          buffer:22x80kb cache:1x5000kb userfacts:100WordNet: dict=201350  fact=85710  stext=12703744 Jul26'16-21:58:46Build0:  dict=67726  fact=130289  stext=1145656 Jul31'16-13:45:49 0Build1:  dict=167  fact=15  stext=211304 Jul31'16-13:45:44 harryUsed 53MB: dict 269,244 (23693kb) hashdepth 18/1 fact 216,014 (8640kb) text 14183kb           buffer (1760kb) cache (5000kb) POS: 918 (29kb)Free 79MB: dict 451,651 hash 924 fact 583,986 text 55,816KB
Enter user name: giorgio
HARRY:  Welcome backgiorgio: > what is your name ?HARRY:  My name is Harry.giorgio: > who is Bruce Wilcox?HARRY:  Bruce Wilcox (born 1951) is an artificial intelligence programmer.giorgio: > ok, I have to goHARRY:  Indeed.giorgio: > :quitExiting ChatScript via Quit$

步骤3:编码和调试您的chatbot脚本 (Step 3: Code and debug your chatbot scripts)

Standalone mode makes for an excellent ChatScript development environment. It allows you to run interactive conversations, then interact with them using :commands. This is a special set of interactive command tools for testing and debugging your dialogs during the development and debug phase.

独立模式可提供出色的ChatScript开发环境。 它允许您运行交互式对话,然后使用:commands与之交互。 这是一组特殊的交互式命令工具,用于在开发和调试阶段测试和调试对话框。

Here are a few example commands:

以下是一些示例命令:

# recompile the bot Harry and reset the status of conversations with user giorgio
giorgio: > :build Harry giorgio: > :reset
# request statistics about topic ~pets
giorgio: > :topicstats ~pets    ~pets     gambits 2 responders 2 rejoinders 5 empties 0Concepts 1860 Topics 1 rules 9 empties 0  gambits 2  responders 2 (?: 2 s: 0  u: 0) rejoinders 5
# conversation ...
giorgio: > do you like snakes?HARRY:  I love pythons except ^"Python" (the programming language)
# ask the reason why a rule fired
giorgio: > :why~pets.2.0.5.9.0  ?:  ( << you like snake >> ) I love pythons except Python ( the programming language ) via ~control.5.9.0  u:  ( ) $$currenttopic = %topic ^if 00m( %response  0 ) 00I{ ^nofail ( TOPIC ^rejoinder ( ) ...

Note that you can run :commands to show the full list of available commands.

请注意,您可以运行:commands以显示可用命令的完整列表。

Topics are contained in specific files. For example, the ~pets topic code is contained in pets.top file, which looks like this:

主题包含在特定文件中。 例如,〜 宠物主题代码包含在pets.top文件,它看起来像这样:

topic: ~pets (dog cat pet animal bird fish snake)
?: ( << you like snake >> ) I love pythons except ^"Python" (the programming language)
?: ( << you ~like ~animals >> )  I love all animals.
t: Do you have any pets? #! yes a: ( ~yes ) Great. You like animals.
#! no a: ( ~no ) You don’t like animals?
#! I have two parrots a: ( parrots ) Birds are nice.
#! I have a cat a: ( cat ) I prefer dogs
#! I have a canary a: ( [parrot bird canary finch swallow] ) Birds are nice.
t: I have a dog.

ChatScript is a rule-based engine, where rules are created by humans writers in program scripts through a process called dialog flow scripting. These use a scripting metalanguage (simply called a “script”) as their source code.

ChatScript是一个基于规则的引擎,其中的规则是由人类编写者通过称为对话框流脚本的过程在程序脚本中创建的。 它们使用脚本语言(简称为“脚本”)作为其源代码。

Here what a ChatScript script file looks like:

这里的ChatScript脚本文件如下所示:

## file: food.top#
topic: ~food []
#! I like spinachss: ( I like spinach )    Are you a fan of the Popeye cartoons?
a: ( ~yes )        I used to watch him as a child. Did you lust after Olive Oyl?     b: ( ~no ) Me neither. She was too skinny.     b: ( ~yes ) You probably like skinny models.
a: ( ~no ) What cartoons do you watch?     b: ( none ) You lead a deprived life.     b: ( Mickey Mouse ) The Disney icon.
#! I often eat chickenu: ( ![ not never rarely ] I * ~ingest * ~meat )    You eat meat.
u: ( !~negativeWords I * ~like * ~meat ) You like meat.
?: (do you eat _ [ ham eggs bacon])    I eat ‘_0
?: (do you like _* or _*)    I don’t like ‘_0 so I guess that means I prefer ‘_1.
s: ( ~like ~fruit ![~animal _bear] )    Vegan, you too...
?: (do you eat _~meat)    No, I hate _0.
s: ( I eat _*1 >)   $food = ‘_0   I eat oysters.

You can define your bot’s dialog flows with a script stored as a normal text file. This is much simpler than methods that other chatbot tools use, which often involve browser-based user interfaces, JSON, or XML.

您可以使用存储为普通文本文件的脚本来定义机器人的对话框流。 这比其他chatbot工具使用的方法要简单得多,其他聊天机器人工具通常使用基于浏览器的用户界面,JSON或XML。

Writing your scripts as a text files gives you full control over your dialog flows. You a can easily process and upgrade your conversational code with back-end scripts and tools.

将脚本编写为文本文件可让您完全控制对话框流。 您可以使用后端脚本和工具轻松地处理和升级会话代码。

For example, you could automatically update ChatScript dialog rules based on records in your database.

例如,您可以根据数据库中的记录自动更新ChatScript对话框规则。

You could even use machine learning tools to mine conversations logs. This could reveal all kinds of opportunities for you to improve your dialog flows.

您甚至可以使用机器学习工具来挖掘对话日志。 这可以为您揭示各种改善对话流程的机会。

But these are topics for a future ChatScript article. I’ll leave you to go play with ChatScript on your own.

但是,这些是以后的ChatScript文章的主题。 我会让你自己去玩ChatScript。

Please contribute to its open source codebase, and star it on GitHub!?????

请贡献其开源代码库,并在GitHub上加注星标! ??????

ChatScript/ChatScriptContribute to ChatScript/ChatScript development by creating an account on GitHub.github.com

ChatScript / ChatScript 通过在GitHub上创建一个帐户来促进ChatScript / ChatScript的开发。 github.com

翻译自: https://www.freecodecamp.org/news/chatscript-for-beginners-chatbots-developers-c58bb591da8/

chatscript

相关文章:

web安全浅析

就之前本人主持开发的金融产品所遇到的安全问题&#xff0c;设计部分请参见&#xff1a;http://www.cnblogs.com/shenliang123/p/3835072.html 这里就部分web安全防护就简单的交流&#xff1a; 1.1系统安全 1.1.1 客户端脚本安全 &#xff08;1&#xff09;跨站脚本攻击&#…

HDU 1556 Color the ball

题解&#xff1a;基础的树状数组区间修改&#xff0c;单点查询。 #include <cstdio> #include <cstring> int c[100005],a,b,n; int modify(int x,int num){while(x<n)c[x]num,xx&-x;} int query(int x){int s0;while(x>0)sc[x],x-x&-x;return s;} …

OC协议实现多继承

协议实现多继承 协议实现多继承的话&#xff0c;只是简答的提供了接口&#xff0c;并灭有提供实现的方式。 A #import <Foundation/Foundation.h>NS_ASSUME_NONNULL_BEGINprotocol StuAProtocal <NSObject>// 学生A 会游泳 - (void)swimming;endinterface Stude…

扶梯正确使用_乘坐自动扶梯解释CSS浮动

扶梯正确使用by Kevin Kononenko凯文科诺年科(Kevin Kononenko) 乘坐自动扶梯解释CSS浮动 (CSS Floats Explained By Riding An Escalator) 如果您曾经跳过自动扶梯&#xff0c;那么您可以快速了解浮动。 (If you have ever jumped on an escalator, then you can quickly und…

安卓学习-界面-ui-ListView

ListView继承自AbsListView AbsListView属性 XML属性代码说明 android:choiceMode setChoiceMode(int choiceMode) AbsListView.CHOICE_MODE_SINGLEAbsListView.CHOICE_MODE_MULTIPLEAbsListView.CHOICE_MODE_MULTIPLE_MODAL none :无选择模式 singleChoice&#xff1a;允许单…

swift 浮点型字符串的运算

// 1 两个浮点字符串之间的运算 let str1 "1.3"; let str2 "2.4"; let val1 Double(str1); let val2 Double(str2);let val3 CGFloat(Double(str1)!) * CGFloat(Double(str2)!);print(val3);// 2 string 转 double 不失精度 let formattor NumberFo…

为什么要在JavaScript中使用静态类型? (使用Flow进行静态打字的4部分入门)

by Preethi Kasireddy通过Preethi Kasireddy 为什么要在JavaScript中使用静态类型&#xff1f; (使用Flow进行静态打字的4部分入门) (Why use static types in JavaScript? (A 4-part primer on static typing with Flow)) As a JavaScript developer, you can code all day …

客户端如何连接 DataSnap Server 调用服务的方法

一般http访问的地址是 http://localhost:8099/datasnap/rest/TServerMethods1/EchoString/abc 一、用FDConnection1连接Datasnap服务器 FireDAC 连接Datasnap服务端。这个是tcp协议连接通讯&#xff0c;长连接。服务端不是没个方法都建立实例释放实例&#xff0c;而是连接的时…

Solr_全文检索引擎系统

Solr介绍&#xff1a; Solr 是Apache下的一个顶级开源项目&#xff0c;采用Java开发&#xff0c;它是基于Lucene的全文搜索服务。Solr可以独立运行在Jetty、Tomcat等这些Servlet容器中。 Solr的作用&#xff1a; solr是一个现成的全文检索引擎系统&#xff0c; 放入tomcat下可以…

swift 数组 filter reduce sort 等方法

数组的常用方法 swift 数组有很多的操作方法&#xff0c;但是用的时候用常常想不起来&#xff0c;就列出来看看 map 和 flatMap对数组中的元素进行变形操作filter主要对数组进行过滤reduce主要对数组进行计算sort对数组进行排序forEach循环遍历每一个元素min 和 max找出数组中…

im和音视频开发哪个更好_找时间成为更好的开发人员

im和音视频开发哪个更好There’s no time for anything. At least that’s how it feels doesn’t it? No time to learn all the things you think you need to learn to stay ahead of the curve. No time to go back and refactor that ugly piece of code. It works (sort…

4-8 同义词

雅思阅读&#xff1a;剑4~剑8阅读的所有同义词转换 雅思必考词汇 Cambridge 4 TEST 1 1. ignorepay no attentionnot pay any attentiontake no noticenot take any notice忽略&#xff0c;无视v. 2. encounterfaceconfrontmeet遇见&#xff0c;遭遇v. 3. mistaken viewmisconc…

swift可选类型

import UIKitvar array1 ["1","2","3","4","5"];// 1 if let 是一个组合关键字 来进行可选绑定 // 解决Optional对象解包时产生空对象的处理。 for i in array1 {print(i); }if let idx array1.firstIndex(of: "4&q…

java 配置及Eclipse安装

jdk下载 点我~ Java SE Development Kit 8u20 You must accept the Oracle Binary Code License Agreement for Java SE to download this software. Accept License Agreement Decline License Agreement Thank you for accepting the Oracle Binary Code License Agree…

golang 命令行_如何使用Golang编写快速有趣的命令行应用程序

golang 命令行by Peter Benjamin彼得本杰明(Peter Benjamin) 如何使用Golang编写快速有趣的命令行应用程序 (How to write fast, fun command-line applications with Golang) A while back, I wrote an article about “Writing Command-Line Applications in NodeJS”.不久前…

【Pyhon 3】: 170104:优品课堂: GUI -tkinter

from tkinter import * root Tk() root.title("BMS 图书管理系统") lbl Label(root, text书名:)#(1) lbl.pack() #(2) lbl.place(45.50) #(3) web 早期布局&#xff0c;&#xff0c; 常见。 lbl.grid(row0, column0) # web 早期布局&#xff0c;&#xff0c; 常见…

swift Sequence 和 SubSequence

1 序列 Sequence 序列协议是集合类型结构中的基础。 一个序列是代表有一系列具有相同类型的值&#xff0c;并且对这些值进行迭代。 协议中主要有两个参数&#xff0c;一个是元素Element&#xff0c;一个就是迭代器Iterator /// A type representing the sequences elements.…

PDF数据提取------1.介绍

1.关于PDF文件 PDF&#xff08;Portable Document Format的简称&#xff0c;意为“便携式文件格式”&#xff09;是由Adobe Systems在1993年用于文件交换所发展出的文件格式。它的优点在于跨平台、能保留文件原有格式&#xff08;Layout&#xff09;、开放标准&#xff0c;能自…

javascript_治愈JavaScript疲劳的研究计划

javascriptby Sacha Greif由Sacha Greif 治愈JavaScript疲劳的研究计划 (A Study Plan To Cure JavaScript Fatigue) Like everybody else, I recently came across Jose Aguinaga’s post “How it feels to learn JavaScript in 2016”.像其他所有人一样&#xff0c;我最近遇…

SQL Server中SELECT会真的阻塞SELECT吗?

在SQL Server中&#xff0c;我们知道一个SELECT语句执行过程中只会申请一些意向共享锁(IS) 与共享锁(S), 例如我使用SQL Profile跟踪会话86执行SELECT * FROM dbo.TEST WHERE OBJECT_ID 1 这个查询语句&#xff0c;其申请、释放的锁资源的过程如下所示&#xff1a; 而且从最常见…

appium IOS真机测试

看了 http://blog.csdn.net/today520/article/details/36378805 的文章&#xff0c;终于在真机上面测试成功。 由于没有开发者账号&#xff0c;不能发布应用到机器上面。所以就用了网易新闻的客户端来测试 没有开发者账号&#xff0c;貌似不能真正的开始测试。只能启动一下客户…

siwft 写时复制 Copy-On-Write

写时复制 Copy-On-Write 1 定义 在siwft 标准库中&#xff0c;Array&#xff0c;Dictionary&#xff0c;Set这样的集合类型是通过写时复制来实现的。 import Foundationvar a1 [1,2,3]; var a2 a1;// 将a1 复制给 a2&#xff0c;地址打印结果是相同的// 0x1--0x2--0x3 pri…

超越技术分析_超越技术面试

超越技术分析by Jaime J. Rios由Jaime J. Rios 超越技术面试 (Transcending the Technical Interview) “Wow. What a chastening and shameful experience that was.”“哇。 那真是一种令人st目结舌的经历。” This was my immediate mental reaction after I completed my…

轻松获取LAMP,LNMP环境编译参数配置

轻松获取LAMP&#xff0c;LNMP环境编译参数配置 作者:Mr.Xiong /分类:系统管理 字号&#xff1a;L M S大家是否遇到过去了新公司&#xff0c;公司内的LAMP&#xff0c;LNMP等所有的环境都是配置好的&#xff08;已经在提供服务了&#xff09;&#xff0c;公司又没有留下部署文档…

java内存分配--引用

栈内存 对象地址 堆内存 存放属性 public class TestDemo{ public static void main(String args[]){ Person perA new Person(); //出现new百分之百就是要申请堆内存 perA.name"王强"&#xff1b; //perA 地址存放在栈内存中&#xff0c;同一块内存只能存…

iOS NSObject对象内存大小

NSObject内存大小 类的本质是结构体 无须赘述 struct NSObject { Class isa; };一个类对象的实例大小是8个字节 之所以打印出的16个字节&#xff0c;是因为一个NSObject 最小开辟16个字节 NSObject *obj [[NSObject alloc]init];// class_getInstanceSize 这是runtime 获…

客户端渲染 服务端渲染_这就是赢得客户端渲染的原因

客户端渲染 服务端渲染A decade ago, nearly everyone was rendering their web applications on the server using technologies like ASP.NET, Ruby on Rails, Java, and PHP.十年前&#xff0c;几乎每个人都使用ASP.NET&#xff0c;Ruby on Rails&#xff0c;Java和PHP等技术…

java多线程三之线程协作与通信实例

多线程的难点主要就是多线程通信协作这一块了&#xff0c;前面笔记二中提到了常见的同步方法&#xff0c;这里主要是进行实例学习了&#xff0c;今天总结了一下3个实例&#xff1a; 1、银行存款与提款多线程实现&#xff0c;使用Lock锁和条件Condition。 附加 &#xff1a;…

Java8中Lambda表达式的10个例子

Java8中Lambda表达式的10个例子 例1 用Lambda表达式实现Runnable接口 Java代码 //Before Java 8: new Thread(new Runnable() { Override public void run() { System.out.println("Before Java8, too much code for too little to do"); } }).start(); …

OC的对象的分类

OC的对象分类 一 oc的对象分类主要分为3种 1 instance 对象&#xff1a; 实例对象就是通过alloc 出来的对象&#xff0c;一个类每一次的alloc都会产生一个新的实例对象 StudentA *a [[StudentA alloc]init];StudentA *b [[StudentA alloc]init];// 打印结果如下 地址是明显…