Skip to content

Commit 5dc94ff

Browse files
committed
Imported Chatterbot Corpus and trained the bot
1 parent b638b00 commit 5dc94ff

File tree

1 file changed

+136
-8
lines changed

1 file changed

+136
-8
lines changed

Chatterbot.ipynb

+136-8
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"colab": {
66
"name": "Chatterbot.ipynb",
77
"provenance": [],
8-
"authorship_tag": "ABX9TyNPtzmb+v4dT/M8GC0x7pRs",
8+
"authorship_tag": "ABX9TyPClhcvRnrxaETYnMfCehpV",
99
"include_colab_link": true
1010
},
1111
"kernelspec": {
@@ -28,22 +28,22 @@
2828
"cell_type": "code",
2929
"metadata": {
3030
"id": "d7DQWH3k_27c",
31-
"outputId": "154c2200-e7a0-403e-d8bb-823d284fd208",
31+
"outputId": "d494a712-c94f-468d-a1e5-54d80e15cd0a",
3232
"colab": {
3333
"base_uri": "https://localhost:8080/"
3434
}
3535
},
3636
"source": [
3737
"!pip install chatterbot"
3838
],
39-
"execution_count": null,
39+
"execution_count": 3,
4040
"outputs": [
4141
{
4242
"output_type": "stream",
4343
"text": [
4444
"Collecting chatterbot\n",
4545
"\u001b[?25l Downloading https://files.pythonhosted.org/packages/7c/21/85c2b114bd9dfabdd46ba58fc4519acdaed45d8c70898d40079e37a45e67/ChatterBot-1.0.8-py2.py3-none-any.whl (63kB)\n",
46-
"\u001b[K |████████████████████████████████| 71kB 1.9MB/s \n",
46+
"\r\u001b[K |█████▏ | 10kB 16.1MB/s eta 0:00:01\r\u001b[K |██████████▎ | 20kB 21.7MB/s eta 0:00:01\r\u001b[K |███████████████▌ | 30kB 20.4MB/s eta 0:00:01\r\u001b[K |████████████████████▋ | 40kB 11.5MB/s eta 0:00:01\r\u001b[K |█████████████████████████▊ | 51kB 7.4MB/s eta 0:00:01\r\u001b[K |███████████████████████████████ | 61kB 7.9MB/s eta 0:00:01\r\u001b[K |████████████████████████████████| 71kB 4.6MB/s \n",
4747
"\u001b[?25hRequirement already satisfied: sqlalchemy<1.4,>=1.3 in /usr/local/lib/python3.6/dist-packages (from chatterbot) (1.3.20)\n",
4848
"Collecting mathparse<0.2,>=0.1\n",
4949
" Downloading https://files.pythonhosted.org/packages/c3/e5/4910fb85950cb960fcf3f5aabe1c8e55f5c9201788a1c1302b570a7e1f84/mathparse-0.1.2-py3-none-any.whl\n",
@@ -57,6 +57,34 @@
5757
}
5858
]
5959
},
60+
{
61+
"cell_type": "code",
62+
"metadata": {
63+
"id": "3zpUf0IjJ9aO",
64+
"outputId": "41f12228-3152-4f5e-f5ab-62ea13c9e744",
65+
"colab": {
66+
"base_uri": "https://localhost:8080/"
67+
}
68+
},
69+
"source": [
70+
"!pip install chatterbot_corpus"
71+
],
72+
"execution_count": 4,
73+
"outputs": [
74+
{
75+
"output_type": "stream",
76+
"text": [
77+
"Collecting chatterbot_corpus\n",
78+
"\u001b[?25l Downloading https://files.pythonhosted.org/packages/ed/19/f8b41daf36fe4b0f43e283a820362ffdb2c1128600ab4ee187e84262fa4d/chatterbot_corpus-1.2.0-py2.py3-none-any.whl (117kB)\n",
79+
"\r\u001b[K |██▉ | 10kB 16.9MB/s eta 0:00:01\r\u001b[K |█████▋ | 20kB 22.5MB/s eta 0:00:01\r\u001b[K |████████▍ | 30kB 14.0MB/s eta 0:00:01\r\u001b[K |███████████▏ | 40kB 9.4MB/s eta 0:00:01\r\u001b[K |██████████████ | 51kB 5.6MB/s eta 0:00:01\r\u001b[K |████████████████▊ | 61kB 6.5MB/s eta 0:00:01\r\u001b[K |███████████████████▋ | 71kB 7.4MB/s eta 0:00:01\r\u001b[K |██████████████████████▍ | 81kB 8.2MB/s eta 0:00:01\r\u001b[K |█████████████████████████▏ | 92kB 8.5MB/s eta 0:00:01\r\u001b[K |████████████████████████████ | 102kB 8.7MB/s eta 0:00:01\r\u001b[K |██████████████████████████████▊ | 112kB 8.7MB/s eta 0:00:01\r\u001b[K |████████████████████████████████| 122kB 8.7MB/s \n",
80+
"\u001b[?25hRequirement already satisfied: PyYAML<4.0,>=3.12 in /usr/local/lib/python3.6/dist-packages (from chatterbot_corpus) (3.13)\n",
81+
"Installing collected packages: chatterbot-corpus\n",
82+
"Successfully installed chatterbot-corpus-1.2.0\n"
83+
],
84+
"name": "stdout"
85+
}
86+
]
87+
},
6088
{
6189
"cell_type": "code",
6290
"metadata": {
@@ -65,7 +93,7 @@
6593
"source": [
6694
"from chatterbot import ChatBot"
6795
],
68-
"execution_count": null,
96+
"execution_count": 5,
6997
"outputs": []
7098
},
7199
{
@@ -74,20 +102,120 @@
74102
"id": "34JnpuLFAk67"
75103
},
76104
"source": [
77-
"bot= ChatBot(\"Buddy\")"
105+
"bot = ChatBot(\n",
106+
" 'Pranav', \n",
107+
" logic_adapters=[\n",
108+
" 'chatterbot.logic.BestMatch',\n",
109+
" 'chatterbot.logic.TimeLogicAdapter'],\n",
110+
")"
78111
],
79-
"execution_count": null,
112+
"execution_count": 6,
80113
"outputs": []
81114
},
82115
{
83116
"cell_type": "code",
84117
"metadata": {
85118
"id": "1HIfQfQNAqP0"
86119
},
120+
"source": [
121+
"from chatterbot.trainers import ListTrainer"
122+
],
123+
"execution_count": 7,
124+
"outputs": []
125+
},
126+
{
127+
"cell_type": "code",
128+
"metadata": {
129+
"id": "OFLmWD_ZKQvG"
130+
},
131+
"source": [
132+
"trainer = ListTrainer(bot)"
133+
],
134+
"execution_count": 8,
135+
"outputs": []
136+
},
137+
{
138+
"cell_type": "code",
139+
"metadata": {
140+
"id": "47NnbZQsKT_w",
141+
"outputId": "b25df833-c3bd-45c1-a019-354d2ae09b98",
142+
"colab": {
143+
"base_uri": "https://localhost:8080/"
144+
}
145+
},
146+
"source": [
147+
"trainer.train([\n",
148+
"'Hi',\n",
149+
"'Hello',\n",
150+
"'I need your assistance regarding my order',\n",
151+
"'Please, Provide me with your order id',\n",
152+
"'I have a complaint.',\n",
153+
"'Please elaborate, your concern',\n",
154+
"'How long it will take to receive an order ?',\n",
155+
"'An order takes 3-5 Business days to get delivered.',\n",
156+
"'Okay Thanks',\n",
157+
"'No Problem! Have a Good Day!'\n",
158+
"])"
159+
],
160+
"execution_count": 9,
161+
"outputs": [
162+
{
163+
"output_type": "stream",
164+
"text": [
165+
"List Trainer: [####################] 100%\n"
166+
],
167+
"name": "stdout"
168+
}
169+
]
170+
},
171+
{
172+
"cell_type": "code",
173+
"metadata": {
174+
"id": "Q-6-d-l9KbQ-",
175+
"outputId": "a3d5ec42-3c38-4775-8ab3-acc791ea8ee1",
176+
"colab": {
177+
"base_uri": "https://localhost:8080/"
178+
}
179+
},
180+
"source": [
181+
"name=input(\"Enter Your Name: \")\n",
182+
"print(\"Welcome to the Bot Service! Let me know how can I help you?\")\n",
183+
"while True:\n",
184+
" request=input(name+':')\n",
185+
" if request=='Bye' or request =='bye':\n",
186+
" print('Bot: Bye')\n",
187+
" break\n",
188+
" else:\n",
189+
" response=bot.get_response(request)\n",
190+
" print('Bot:',response)"
191+
],
192+
"execution_count": 13,
193+
"outputs": [
194+
{
195+
"output_type": "stream",
196+
"text": [
197+
"Enter Your Name: Pranav\n",
198+
"Welcome to the Bot Service! Let me know how can I help you?\n",
199+
"Pranav:Hi\n",
200+
"Bot: Hello\n",
201+
"Pranav:What is the Time\n",
202+
"Bot: The current time is 10:27 PM\n",
203+
"Pranav:bye\n",
204+
"Bot: Bye\n"
205+
],
206+
"name": "stdout"
207+
}
208+
]
209+
},
210+
{
211+
"cell_type": "code",
212+
"metadata": {
213+
"id": "-4NVLkLgKkli"
214+
},
87215
"source": [
88216
""
89217
],
90-
"execution_count": null,
218+
"execution_count": 13,
91219
"outputs": []
92220
}
93221
]

0 commit comments

Comments
 (0)