Use of Chatterbot MongoDB 03

Source: Internet
Author: User
Tags install mongodb chatterbot

In the previous article we have built the MONGODB environment, this is a simple example.

Not much nonsense to say the first code and then start to explain;

!!! Don't forget to open your mongdb service!!!, if there is no MongoDB please look at the article how to install MongoDB;

#-*-coding:utf-8-*- fromChatterbot Import Chatbot fromchatterbot.trainers Import Listtrainer fromchatterbot.trainers Import Chatterbotcorpustrainerimport logging# Uncomment the following line to enable verbose Logg Ing#logging.basicconfig ( level=logging.info) # Create aNewchatbot Instancechatbot=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 ...') whileTrue: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 Conditions Repetitiveresponsefilter, This is a filter, its role is to filter out the repeated answers;

2.database="chatterbot-1w", then your database name, if not, for the first time he will automatically create;

3.database_uri="mongodb://192.168.2.128:27017/", which is the address port number where you set your database ;

4.read_only=True

Chatterbot is the one that learns each input statement. If you want to make the bot you have already trained no longer continue to learn the input statements, you can set the READ_ONLY to true at initialization time by using the following method.

As for how to train, please listen to tell;

Use of Chatterbot MongoDB 03

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.