ChatterBot README

The project's README from github.com/gunthercox/ChatterBot. As one markdown file: README.md.

ChatterBot: Machine learning in Python

ChatterBot

ChatterBot is a machine-learning based conversational dialog engine built in Python which makes it possible to generate responses based on collections of known conversations. The language independent design of ChatterBot allows it to be trained to speak any language.

Package Version Python 3.12 Coverage Status Follow on Bluesky Join the chat at https://gitter.im/chatterbot/Lobby

An example of typical input would be something like this:

user: Good morning! How are you doing?
bot: I am doing very well, thank you for asking.
user: You're welcome.
bot: Do you like hats?

How it works

An untrained instance of ChatterBot starts off with no knowledge of how to communicate. Each time a user enters a statement, the library saves the text that they entered and the text that the statement was in response to. As ChatterBot receives more input the number of responses that it can reply to, and the accuracy of each response in relation to the input statement increases. The program selects the closest matching response by searching for the closest matching known statement that matches the input, it then returns the most likely response to that statement based on how frequently each response is issued by the people the bot communicates with.

Documentation

View the documentation for ChatterBot.

Installation

This package can be installed from PyPi by running:

pip install chatterbot

Basic Usage

from chatterbot import ChatBot
from chatterbot.trainers import ChatterBotCorpusTrainer

chatbot = ChatBot('Ron Obvious')

# Create a new trainer for the chatbot
trainer = ChatterBotCorpusTrainer(chatbot)

# Train the chatbot based on the english corpus
trainer.train("chatterbot.corpus.english")

# Get a response to an input statement
chatbot.get_response("Hello, how are you today?")

Training data

ChatterBot comes with a data utility module that can be used to train chat bots. At the moment there is training data for over a dozen languages in this module. Contributions of additional training data or training data in other languages would be greatly appreciated. Take a look at the data files in the chatterbot-corpus package if you are interested in contributing.

from chatterbot.trainers import ChatterBotCorpusTrainer

# Create a new trainer for the chatbot
trainer = ChatterBotCorpusTrainer(chatbot)

# Train based on the english corpus
trainer.train("chatterbot.corpus.english")

# Train based on english greetings corpus
trainer.train("chatterbot.corpus.english.greetings")

# Train based on the english conversations corpus
trainer.train("chatterbot.corpus.english.conversations")

Corpus contributions are welcome! Please make a pull request.

Examples

For examples, see the examples section of the documentation.

History

See release notes for changes https://github.com/gunthercox/ChatterBot/releases

Contributing

Contributions are welcomed, to help ensure a smooth process please start with the contributing guidelines in our documentation: https://docs.chatterbot.us/contributing/

Sponsors

ChatterBot is sponsored by:

License

ChatterBot is licensed under the BSD 3-clause license.

ChatterBot (gunthercox/ChatterBot)

Searching Database…

这是什么东西?ChatterBot 是一个基于机器学习的 Python 对话引擎:它根据已知对话集合生成聊天机器人的回复,并且可以训练成说任何语言。
那它是一个让我在上面开发的 Python 库,还是一个可以直接运行的成品聊天机器人?它是一个库:你安装这个包,然后在自己的 Python 代码里搭建机器人——没有可以单独运行的应用程序。
怎么把它加到我的项目里?用 pip 从 PyPI 安装(pip install chatterbot),然后在你的 Python 代码里导入它;文档里有一个 Basic Usage(基本用法)章节,可以从那里入门。
除了 Python 之外还需要装别的东西吗?只需要一个 Python 环境就行:这个包从 PyPI 安装,依赖会由 pip 自动解决。
装好之后就能直接用吗,还是得先训练?需要先训练:新建的实例一开始完全不会交流。它会在用户和它聊天的过程中不断学习,你也可以用自带的训练数据先给它打底。
它是怎么决定用哪句话回复我的?它会找出与你的输入最接近的已知语句,然后根据人们过去对这个语句做出某种回复的频率,返回最可能的回复。
和它聊天的人越多,它就越好用吗?是的。用户输入的每一条语句都会连同它所回应的内容一起保存下来,所以可用的回复以及回复的准确度会随着每一次对话不断增长。
能用英语以外的语言训练它吗?可以——它的设计是与语言无关的,自带的数据工具模块包含了十多种语言的训练数据,也欢迎大家贡献语料。
What are similar projects?rasa, ParlAI, flair, botpress, awesome-nlp, spaCy, Hy-MT2, bert
Creator
gunthercox
Size
8.2 MB
Stars
14.5K
Age
12y
Commits · 90 Days