|
5 | 5 | "colab": {
|
6 | 6 | "name": "Chatterbot.ipynb",
|
7 | 7 | "provenance": [],
|
8 |
| - "authorship_tag": "ABX9TyNPtzmb+v4dT/M8GC0x7pRs", |
| 8 | + "authorship_tag": "ABX9TyPClhcvRnrxaETYnMfCehpV", |
9 | 9 | "include_colab_link": true
|
10 | 10 | },
|
11 | 11 | "kernelspec": {
|
|
28 | 28 | "cell_type": "code",
|
29 | 29 | "metadata": {
|
30 | 30 | "id": "d7DQWH3k_27c",
|
31 |
| - "outputId": "154c2200-e7a0-403e-d8bb-823d284fd208", |
| 31 | + "outputId": "d494a712-c94f-468d-a1e5-54d80e15cd0a", |
32 | 32 | "colab": {
|
33 | 33 | "base_uri": "https://localhost:8080/"
|
34 | 34 | }
|
35 | 35 | },
|
36 | 36 | "source": [
|
37 | 37 | "!pip install chatterbot"
|
38 | 38 | ],
|
39 |
| - "execution_count": null, |
| 39 | + "execution_count": 3, |
40 | 40 | "outputs": [
|
41 | 41 | {
|
42 | 42 | "output_type": "stream",
|
43 | 43 | "text": [
|
44 | 44 | "Collecting chatterbot\n",
|
45 | 45 | "\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", |
47 | 47 | "\u001b[?25hRequirement already satisfied: sqlalchemy<1.4,>=1.3 in /usr/local/lib/python3.6/dist-packages (from chatterbot) (1.3.20)\n",
|
48 | 48 | "Collecting mathparse<0.2,>=0.1\n",
|
49 | 49 | " Downloading https://files.pythonhosted.org/packages/c3/e5/4910fb85950cb960fcf3f5aabe1c8e55f5c9201788a1c1302b570a7e1f84/mathparse-0.1.2-py3-none-any.whl\n",
|
|
57 | 57 | }
|
58 | 58 | ]
|
59 | 59 | },
|
| 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 | + }, |
60 | 88 | {
|
61 | 89 | "cell_type": "code",
|
62 | 90 | "metadata": {
|
|
65 | 93 | "source": [
|
66 | 94 | "from chatterbot import ChatBot"
|
67 | 95 | ],
|
68 |
| - "execution_count": null, |
| 96 | + "execution_count": 5, |
69 | 97 | "outputs": []
|
70 | 98 | },
|
71 | 99 | {
|
|
74 | 102 | "id": "34JnpuLFAk67"
|
75 | 103 | },
|
76 | 104 | "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 | + ")" |
78 | 111 | ],
|
79 |
| - "execution_count": null, |
| 112 | + "execution_count": 6, |
80 | 113 | "outputs": []
|
81 | 114 | },
|
82 | 115 | {
|
83 | 116 | "cell_type": "code",
|
84 | 117 | "metadata": {
|
85 | 118 | "id": "1HIfQfQNAqP0"
|
86 | 119 | },
|
| 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 | + }, |
87 | 215 | "source": [
|
88 | 216 | ""
|
89 | 217 | ],
|
90 |
| - "execution_count": null, |
| 218 | + "execution_count": 13, |
91 | 219 | "outputs": []
|
92 | 220 | }
|
93 | 221 | ]
|
|
0 commit comments