{ "cells": [ { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Training restaurant.yml: [####################] 100%\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "[nltk_data] Downloading package stopwords to\n", "[nltk_data] C:\\Users\\thumt\\AppData\\Roaming\\nltk_data...\n", "[nltk_data] Package stopwords is already up-to-date!\n", "[nltk_data] Downloading package averaged_perceptron_tagger to\n", "[nltk_data] C:\\Users\\thumt\\AppData\\Roaming\\nltk_data...\n", "[nltk_data] Package averaged_perceptron_tagger is already up-to-\n", "[nltk_data] date!\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Text : ปลาโลมา\n", "Bot: หมดครับ\n", "Text : มีปลาอะไร\n", "Bot: ปลาเก๋า ปลาทู ปลาโลมา\n", "Text : ปลาทู\n", "Bot: ได้ครับ\n", "Text : ปลาโลมา\n", "Bot: หมดครับ\n", "Text : ไม่เผ็ด\n", "Bot: พริกกี่เม็ดดีครับ\n", "Text : ขอเปลี่ยนใจ\n", "Bot: รับอะไรดีครับ\n", "Text : exit\n" ] } ], "source": [ "#from chatterbot.trainers import ChatterBotCorpusTrainer\n", "\n", "#chatterbot = ChatBot(\"Training Example\") # ชื่อแชทบ็อต\n", "#chatterbot.set_trainer(ChatterBotCorpusTrainer) # กำหนดให้ Train จากชุดข้อมูลของ Chatterbot\n", "\n", "#chatterbot.train(\n", "# \"chatterbot.corpus.english\"\n", "#) # เรียกใช้ชุดข้อมูล chatterbot.corpus.english\n", "\n", "from chatterbot import ChatBot\n", "from chatterbot.trainers import ChatterBotCorpusTrainer\n", "\n", "chatbot = ChatBot('Training Example')\n", "trainer = ChatterBotCorpusTrainer(chatbot)\n", "\n", "trainer.train(\n", " \"chatterbot.corpus.thai\"\n", ")\n", "\n", "\n", "text=\"\"\n", "\n", "while True:\n", "\n", " text=input(\"Text : \")\n", "\n", " if text==\"exit\":\n", "\n", " break\n", "\n", " response = chatbot.get_response(text)\n", "\n", " print('Bot: ',response)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.4" } }, "nbformat": 4, "nbformat_minor": 2 }