-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds a tutorial on how to use the MongoDB adapter. This also adds information about training a chat bot.
- Loading branch information
1 parent
8856bce
commit a5486b6
Showing
15 changed files
with
201 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,6 @@ language: python | |
|
||
python: | ||
- '3.4' | ||
- '3.3' | ||
- '2.7' | ||
|
||
install: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from chatterbot.adapters.logic import LogicAdapter | ||
from chatterbot.conversation import Statement | ||
|
||
|
||
class NoLogic(LogicAdapter): | ||
|
||
def can_process(self, statement): | ||
""" | ||
Determines if this adapter can respond to the input. | ||
""" | ||
return True | ||
|
||
def process(self, statement): | ||
import random | ||
|
||
# Get all statements that are in response to the closest match | ||
response_list = self.context.storage.filter( | ||
in_response_to__contains=statement.text | ||
) | ||
|
||
return 1, random.choice(response_list) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
============== | ||
Input Adapters | ||
============== | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
============== | ||
Logic Adapters | ||
============== | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
=============== | ||
Output Adapters | ||
=============== | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
======== | ||
Training | ||
======== | ||
|
||
ChatterBot has tools that simplify the process of training a bot instance. | ||
These tools range from simple utility methods that update relations of known | ||
statements, to a corpus of pre-loaded training data that you can use. | ||
|
||
Training via list data | ||
====================== | ||
|
||
For the training, process, you will need to pass in a list of statements where the order of each statement is based on it's placement in a given conversation. | ||
|
||
For example, if you were to run bot of the following training calls, then the resulting chatterbot would respond to both statements of "Hi there!" and "Greetings!" by saying "Hello". | ||
|
||
.. code-block:: python | ||
chatterbot = ChatBot("Training Example") | ||
chatterbot.train([ | ||
"Hi there!", | ||
"Hello", | ||
]) | ||
chatterbot.train([ | ||
"Greetings!", | ||
"Hello", | ||
]) | ||
You can also provide longer lists of training conversations. | ||
This will establish each item in the list as a possible response to it's predecessor in the list. | ||
|
||
.. code-block:: python | ||
chatterbot.train([ | ||
"How are you?", | ||
"I am good.", | ||
"That is good to hear.", | ||
"Thank you", | ||
"You are welcome.", | ||
]) | ||
Training with corpus data | ||
========================= | ||
|
||
ChatterBot comes with a corpus data and utility module that makes it easy to | ||
quickly train your bot to communicate. To do so, simply specify the corpus | ||
data modules you want to use. | ||
|
||
.. code-block:: python | ||
chatterbot.train( | ||
"chatterbot.corpus.english" | ||
) | ||
Specifying corpus scope | ||
----------------------- | ||
|
||
It is also possible to import individual subsets of ChatterBot's at once. | ||
For example, if you only wish to train based on the english greetings and | ||
conversations corpora then you would simply specify them. | ||
|
||
.. code-block:: python | ||
chatterbot.train( | ||
"chatterbot.corpus.english.greetings", | ||
"chatterbot.corpus.english.conversations" | ||
) | ||
The ChatterBot Corpus | ||
===================== | ||
|
||
This is a :term:`corpus` of data that is included in the chatterbot module. | ||
|
||
Corpus language availability | ||
---------------------------- | ||
|
||
Corpus data is user contributed, but it is also not difficult to create one if you are familiar with the language. | ||
This is because each corpus is just a sample of various input statements and their responses for the bot to train itself with. | ||
|
||
To explore what languages and sets of corpora are available, check out the `chatterbot/corpus/data`_ directory in the repository. | ||
|
||
If you are interested in contributing a new language corpus, or adding a module to an existing language, please create a pull request. Contributions are welcomed! | ||
|
||
.. glossary:: | ||
|
||
corpus | ||
In linguistics, a corpus (plural corpora) or text corpus is a large | ||
and structured set of texts. They are used to do statistical analysis | ||
and hypothesis testing, checking occurrences or validating linguistic | ||
rules within a specific language territory [1]_. | ||
|
||
.. [1] https://en.wikipedia.org/wiki/Text_corpus | ||
.. _chatterbot/corpus/data: https://github.com/gunthercox/ChatterBot/tree/master/chatterbot/corpus |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters