ChatterBot之使用mongodb 03
上一篇我们已经搭建好了mongodb环境,本篇为简单示例.
废话不多说先上代码然后开始讲解;
!!!别忘了打开你的mongdb服务!!!,如果没有mongodb请看上篇如何安装mongodb;
# -*- coding: utf- -*- from chatterbot import ChatBot
from chatterbot.trainers import ListTrainer
from chatterbot.trainers import ChatterBotCorpusTrainer
import logging
# Uncomment the following line to enable verbose logging #logging.basicConfig(level=logging.INFO) # Create a new ChatBot instance chatbot = ChatBot(
'Norman',
storage_adapter='chatterbot.storage.MongoDatabaseAdapter', logic_adapters=[
'chatterbot.logic.BestMatch',
'chatterbot.logic.MathematicalEvaluation',
'chatterbot.logic.TimeLogicAdapter'
],
filters=[
'chatterbot.filters.RepetitiveResponseFilter'
], input_adapter="chatterbot.input.TerminalAdapter",
output_adapter="chatterbot.output.TerminalAdapter",
trainer='chatterbot.trainers.ListTrainer',
database="chatterbot-1w",
database_uri="mongodb://192.168.2.128:27017/",
read_only=True
) print('Type something to begin...') while True:
try:
bot_input = chatbot.get_response(None) # Press ctrl-c or ctrl-d on the keyboard to exit
except (KeyboardInterrupt, EOFError, SystemExit):
break;
1.filters条件RepetitiveResponseFilter, 这是一个滤波器,它的作用是滤掉重复的回答;
2.database="chatterbot-1w",这时你的数据库名称,如果没有,首次他会自动创建;
3.database_uri="mongodb://192.168.2.128:27017/", 这是设置你的数据库所在的地址端口号;
4.read_only=True
ChatterBot是会对每个输入的语句进行学习的。如果想要使得你已经训练过的bot不再继续学习输入的语句,可以通过以下方式进行设置,在初始化的时候将read_only设置为True。

关于如如何训练,请听下回分解;
ChatterBot之使用mongodb 03的更多相关文章
- MongoDB学习笔记—03 增删改查操作
MongoDB的CURD操作分别通过函数insert().update().find().remove()进行 MongoDB文档新增与删除 MongoDB中关于文档的新增与删除比较简单.主要通过in ...
- mongodb学习03 操作详解
插入文档 db.test.insert({"name":"jinks"}); 批量插入 db.test.insert([{}, {}, {}]); 一次批量插入 ...
- MongoDB学习笔记03
限制结果的返回数量可以使用limit.skip sort用一个对象作为参数:一组键/值对,键对应文档的键名,值代表排序的方向(1:升序,-1:降序):如果指定了多个键,则按照多个键的顺序诸个排序. M ...
- ChatterBot之linux下安装mongodb 02
当前环境 :centos 6.9 mongodb版本 mongodb-linux-x86_64-3.4.4.tgz 使用链接工具:studio-3t-x64.msi.zip 首先我们先来安装mongo ...
- 第03章:MongoDB启动参数说明
①基本配置 --quiet # 安静输出 --port arg # 指定服务端口号,默认端口27017 --bind_ip arg # 绑定服务IP,若绑定127.0.0.1,则只能本机访问,不指定默 ...
- Mongodb 笔记03 查询、索引
查询 1. MongoDB使用find来进行查询.find的第一个参数决定了要返回哪些文档,这个参数是一个文档,用于指定查询条件.空的查询会匹配集合的全部内容.要是不指定查询,默认是{}. 2. 可以 ...
- MongoDB小结03 - insert、remove
连接MongoDB(bin目录下) ./mongo 如果觉得shell里空空的可以输入help,在刷屏的同时大致了解下有哪些方法 help 现在咱们还没有数据库,咱们创建一个,任性起名:templat ...
- MongoDB for OPS 03:分片 shard 集群
写在前面的话 上一节的复制集也就是主从能够解决我们高可用和数据安全性问题,但是无法解决我们的性能瓶颈问题.所以针对性能瓶颈,我们需要采用分布式架构,也就是分片集群,sharding cluster! ...
- MongoDB系列---集合与文档操作03
MongoDB-——Collection 学习大纲: 1.集合操作 2.文档操作 知识回顾: 上一篇我们讲述了如何对MongoDB的权限和用户进行日常的基本操作,来达到我们对数据库的基本安全保障. 一 ...
随机推荐
- ALV添加文字输入框
一.业务场景 在合同打印中,需要临时添加其他约定事项,在打印程序的ALV中添加其他事项字段,点击之后弹出文字输入窗口,点击确定,文字内容存表,并在ALV中展示,点击打印后,文字内容加载到smartfo ...
- Memcached统计命令
1. Memcached stats命令: Memcached stats 命令用于返回统计信息例如 PID(进程号).版本号.连接数等. 语法: stats 输出信息说明: pid: memcach ...
- angular核心$watch,$digest,$apply之间的联系
浏览器事件发生时,会在浏览器的上下文window中执行,而angular有自己的上下文angular content,angular 事件在自己的上下文angular content中执行. $wat ...
- showmemory.c 和 hello.s 源码
showmemory.c 和 hello.s 源码 /** * showmemory.c -- print the position of different types of data in a p ...
- n! 进制
n! 进制 Time limit per test: 1.0 seconds Time limit all tests: 1.0 seconds Memory limit: 256 megabytes ...
- Sqlserver将数据从一个表插入到另一个表
.如果是整个表复制表达如下: insert into table1 select * from table2 .如果是有选择性的复制数据表达如下: insert into table1(column1 ...
- Maven2的配置文件settings.xml
简介: 概览 当Maven运行过程中的各种配置,例如pom.xml,不想绑定到一个固定的project或者要分配给用户时,我们使用settings.xml中的settings元素来确定这些配置.这包含 ...
- Java实现归并排序和快速排序
参考http://blog.csdn.net/morewindows/article/details/6684558和http://developer.51cto.com/art/201206/344 ...
- 使用MS Test做单元测试
声明:本篇博客翻译自:http://www.c-sharpcorner.com/article/unit-testing-with-ms-tests-in-c-sharp/ 写在翻译之前: 依然清晰的 ...
- python基础-------模块与包(四)
configparser模块与 subprcess 利用configparser模块配置一个类似于 windows.ini格式的文件可以包含一个或多个节(section),每个节可以有多个参数(键=值 ...