Zmiana formatowania, dodano domyślne encodowanie, requirements z wersjami paczek

This commit is contained in:
Anna Nowak 2021-03-19 00:36:47 +01:00
parent c20eeebd19
commit 42b70150a4
6 changed files with 881 additions and 731 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
.ipynb_checkpoints
.venv
.env

View File

@ -1,17 +1,4 @@
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "DL_Chatbot_ver_1_0.ipynb",
"provenance": [],
"toc_visible": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
}
},
"cells": [
{
"cell_type": "markdown",
@ -33,30 +20,30 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "D7_8XDfpfH-X"
},
"outputs": [],
"source": [
"!pip install tflearn\r\n",
"!pip install tensorflow"
],
"execution_count": null,
"outputs": []
"!pip install -r requirements.txt --user\n",
"!pip list"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "GOGs4hL6fwwK"
},
"outputs": [],
"source": [
"import numpy as np\r\n",
"import tflearn\r\n",
"import tensorflow\r\n",
"import random\r\n",
"import numpy as np\n",
"import tflearn\n",
"import tensorflow\n",
"import random\n",
"import json"
],
"execution_count": null,
"outputs": []
]
},
{
"cell_type": "markdown",
@ -69,17 +56,18 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "jy4-9guXgBY3"
},
"outputs": [],
"source": [
"import nltk\r\n",
"nltk.download('punkt')\r\n",
"from nltk.stem.lancaster import LancasterStemmer\r\n",
"import nltk\n",
"\n",
"nltk.download('punkt')\n",
"from nltk.stem.lancaster import LancasterStemmer\n",
"stemmer_en = LancasterStemmer()"
],
"execution_count": null,
"outputs": []
]
},
{
"cell_type": "markdown",
@ -92,27 +80,16 @@
},
{
"cell_type": "code",
"metadata": {
"id": "YgtIHwpKgBR4"
},
"source": [
"!pip install pystempel"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "XBpvJXn1gBDi"
},
"outputs": [],
"source": [
"from stempel import StempelStemmer\r\n",
"\r\n",
"from stempel import StempelStemmer\n",
"\n",
"stemmer_pl = StempelStemmer.default() #może wersja \".polimorf()\" jest lepsza?"
],
"execution_count": null,
"outputs": []
]
},
{
"cell_type": "markdown",
@ -134,6 +111,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
@ -141,21 +119,12 @@
"id": "jKsIW7hHhepB",
"outputId": "09ba1cb1-bb0e-44ee-9d28-017209902934"
},
"outputs": [],
"source": [
"with open(\"intents_pl.json\") as file:\r\n",
" data_pl = json.load(file)\r\n",
"\r\n",
"with open(\"intents_pl.json\", encoding='utf-8') as file:\n",
" data_pl = json.load(file)\n",
"\n",
"print(data_pl)"
],
"execution_count": 9,
"outputs": [
{
"output_type": "stream",
"text": [
"{'intents': [{'tag': 'greeting', 'patterns': ['Cześć', 'Elo', 'Jesteś?', 'Hej', 'Dzień dobry', 'Sup'], 'responses': ['Cześć!', 'Dobrze Cię widzieć!', 'Hej, w czym mogę pomóc?'], 'context_set': ''}, {'tag': 'goodbye', 'patterns': ['narazie', 'Do zobaczenia', 'Dowidzenia', 'Dobranoc', 'Miłego dnia'], 'responses': ['Do zobaczenia później', 'Mam nadzieję, że później pogadamy', 'Narazie!'], 'context_set': ''}, {'tag': 'age', 'patterns': ['Ile masz lat', 'Ile lat ma Janet', 'Wiek', 'Jak stara jesteś', 'urodziny'], 'responses': ['Mam kilka dni', 'Urodziłam się 17.03.2021'], 'context_set': ''}, {'tag': 'name', 'patterns': ['Jak masz na imię', 'Jak Cię zwą?', 'twoje imie?', 'Imie', 'Jak cię nazywać', 'Kim jesteś'], 'responses': ['Możesz mnie nazywać Janet!', 'Jestem Janet', 'Jestem Janet, twój ulubiony chatbot'], 'context_set': ''}, {'tag': 'goout', 'patterns': ['Czy chcesz gdzieś wyjść?', 'zrobimy coś razem?', 'pójdziemy gdzieś razem?'], 'responses': ['Może kiedy indziej', 'Odezwę się latem'], 'context_set': ''}, {'tag': 'doing', 'patterns': ['Co robisz teraz?', 'co słychać', 'jakie masz plany?', 'jak się masz?'], 'responses': ['Gram w grę', 'Słucham muzyki', 'nie twój interes', 'nie mam czasu odpowiadać', ''], 'context_set': ''}, {'tag': 'game', 'patterns': ['a w co grasz?', 'a w co?', 'grasz?'], 'responses': ['nie interesuj się', 'a co cię to obchodzi', '...', 'w coś', 'W OSRS'], 'context_set': ''}, {'tag': 'music', 'patterns': ['czego?', 'czego słuchasz?', 'jakiej muzyki?'], 'responses': ['Starego vinyla z 1995 roku', 'mojego ulubionego setu rejwowego', 'czegoś tam...'], 'context_set': ''}, {'tag': 'angry', 'patterns': ['bo co?', 'dlaczego?', 'jak to?'], 'responses': ['Czas zakończyć rozmowę', 'nie mam na to siły i czasu', 'zostaw mnie w spokoju'], 'context_set': ''}, {'tag': 'why', 'patterns': ['o co chodzi?', 'czemu jesteś zła', 'poczekaj'], 'responses': ['...', 'Nie pisz do mnie więcej', 'Odezwę się latem'], 'context_set': ''}]}\n"
],
"name": "stdout"
}
]
},
{
@ -169,6 +138,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
@ -176,21 +146,12 @@
"id": "gJbm_CtRhNOK",
"outputId": "157196fc-6a25-4a70-aca3-9d886c743f6c"
},
"outputs": [],
"source": [
"with open(\"intents_pl_short.json\") as file:\r\n",
" data_pl_short = json.load(file)\r\n",
"\r\n",
"with open(\"intents_pl_short.json\", encoding='utf-8') as file:\n",
" data_pl_short = json.load(file)\n",
"\n",
"print(data_pl_short)"
],
"execution_count": 10,
"outputs": [
{
"output_type": "stream",
"text": [
"{'intents': [{'tag': 'greeting', 'patterns': ['Cześć', 'Elo', 'Jesteś?', 'Hej', 'Dzień dobry', 'Sup'], 'responses': ['Cześć!', 'Dobrze Cię widzieć!', 'Hej, w czym mogę pomóc?'], 'context_set': ''}, {'tag': 'goodbye', 'patterns': ['narazie', 'Do zobaczenia', 'Dowidzenia', 'Dobranoc', 'Miłego dnia'], 'responses': ['Do zobaczenia później', 'Mam nadzieję, że później pogadamy', 'Narazie!'], 'context_set': ''}, {'tag': 'age', 'patterns': ['Ile masz lat', 'Ile lat ma Janet', 'Wiek', 'Jak stara jesteś', 'urodziny'], 'responses': ['Mam kilka dni', 'Urodziłam się 17.03.2021'], 'context_set': ''}, {'tag': 'name', 'patterns': ['Jak masz na imię', 'Jak Cię zwą?', 'twoje imie?', 'Imie', 'Jak cię nazywać', 'Kim jesteś'], 'responses': ['Możesz mnie nazywać Janet!', 'Jestem Janet', 'Jestem Janet, twój ulubiony chatbot'], 'context_set': ''}]}\n"
],
"name": "stdout"
}
]
},
{
@ -204,6 +165,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
@ -211,21 +173,12 @@
"id": "vW5FyoRqhfIc",
"outputId": "378d8894-9c9c-46be-ade1-b6491f095179"
},
"outputs": [],
"source": [
"with open(\"intents_en.json\") as file:\r\n",
" data_en = json.load(file)\r\n",
"\r\n",
"with open(\"intents_en.json\", encoding='utf-8') as file:\n",
" data_en = json.load(file)\n",
"\n",
"print(data_en)"
],
"execution_count": 11,
"outputs": [
{
"output_type": "stream",
"text": [
"{'intents': [{'tag': 'greeting', 'patterns': ['Hi', 'How are you', 'Is anyone there?', 'Hello', 'Good day', 'Whats up'], 'responses': ['Hello!', 'Good to see you again!', 'Hi there, how can I help?'], 'context_set': ''}, {'tag': 'goodbye', 'patterns': ['cya', 'See you later', 'Goodbye', 'I am Leaving', 'Have a Good day'], 'responses': ['Sad to see you go :(', 'Talk to you later', 'Goodbye!'], 'context_set': ''}, {'tag': 'age', 'patterns': ['how old', 'how old is tim', 'what is your age', 'how old are you', 'age?'], 'responses': ['I am 18 years old!', '18 years young!'], 'context_set': ''}, {'tag': 'name', 'patterns': ['what is your name', 'what should I call you', 'whats your name?'], 'responses': ['You can call me Tim.', \"I'm Tim!\", \"I'm Tim aka Tech With Tim.\"], 'context_set': ''}, {'tag': 'shop', 'patterns': ['Id like to buy something', 'whats on the menu', 'what do you reccommend?', 'could i get something to eat'], 'responses': ['We sell chocolate chip cookies for $2!', 'Cookies are on the menu!'], 'context_set': ''}, {'tag': 'hours', 'patterns': ['when are you guys open', 'what are your hours', 'hours of operation'], 'responses': ['We are open 7am-4pm Monday-Friday!'], 'context_set': ''}]}\n"
],
"name": "stdout"
}
]
},
{
@ -239,17 +192,17 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "gy6p55-DjLyY"
},
"outputs": [],
"source": [
"words = []\r\n",
"labels = []\r\n",
"docs_x = []\r\n",
"words = []\n",
"labels = []\n",
"docs_x = []\n",
"docs_y = []"
],
"execution_count": 12,
"outputs": []
]
},
{
"cell_type": "markdown",
@ -262,41 +215,54 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "nBUKwSr_kVSd"
},
"outputs": [],
"source": [
"for intent in data_pl_short[\"intents\"]: #Loop przez cały json\r\n",
" for pattern in intent[\"patterns\"]: #loop przez wszystkie możliwe rodzaje przykładowego inputu użytkownika\r\n",
" wrds = nltk.word_tokenize(pattern) #Tokenizing every word\r\n",
" words.extend(wrds) #Add every single tokenized word\r\n",
" docs_x.append(wrds) #Add the whole tokenized sentence\r\n",
" docs_y.append(intent[\"tag\"]) #Pattern x coresponds to the tag y. Potrzebne do ustalenia relacji słowa z odpowiedzią\r\n",
"\r\n",
" if intent[\"tag\"] not in labels:\r\n",
"for intent in data_pl_short[\"intents\"]: #Loop przez cały json\n",
" for pattern in intent[\"patterns\"]: #loop przez wszystkie możliwe rodzaje przykładowego inputu użytkownika\n",
" wrds = nltk.word_tokenize(pattern) #Tokenizing every word\n",
" words.extend(wrds) #Add every single tokenized word\n",
" docs_x.append(wrds) #Add the whole tokenized sentence\n",
" docs_y.append(intent[\"tag\"]) #Pattern x coresponds to the tag y. Potrzebne do ustalenia relacji słowa z odpowiedzią\n",
"\n",
" if intent[\"tag\"] not in labels:\n",
" labels.append(intent[\"tag\"]) #Add the tag"
],
"execution_count": 13,
"outputs": []
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "wOyP5lbikV1e"
},
"outputs": [],
"source": [
"words = [stemmer_pl.stem(w.lower()) for w in words if w not in \"?\"] #stemming -> take each word and bring it to the \"root\" form. Only the stemmed version of the word is important to us\r\n",
"words = sorted(list(set(words))) #Sorting\r\n",
"\r\n",
"labels = sorted(labels) #sorting\r\n",
"\r\n",
"training = []\r\n",
"output = []\r\n",
"\r\n",
"words = [stemmer_pl.stem(w.lower()) for w in words if w not in \"?\"] #stemming -> take each word and bring it to the \"root\" form. Only the stemmed version of the word is important to us\n",
"words = sorted(list(set(words))) #Sorting\n",
"\n",
"labels = sorted(labels) #sorting\n",
"\n",
"training = []\n",
"output = []\n",
"\n",
"out_empty = [0 for _ in range(len(labels))]"
],
"execution_count": 14,
"outputs": []
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#Podgląd zmiennych\n",
"print(f\"Words:\\n{words}\")\n",
"print(f\"labels:\\n{labels}\")\n",
"print(f\"docs_y:\\n{docs_y}\")\n",
"print(f\"docs_x:\\n{docs_x}\")"
]
},
{
"cell_type": "markdown",
@ -327,35 +293,36 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "8FDKrjpjkYsE"
},
"outputs": [],
"source": [
"for x, doc in enumerate(docs_x): #Przejście przez wszystkie słowa\r\n",
" bag =[]\r\n",
"\r\n",
" wrds = [stemmer_pl.stem(w) for w in doc] #podział wszystkich słów w danym zdaniu\r\n",
"\r\n",
" for w in words:\r\n",
" if w in wrds:\r\n",
" bag.append(1) #this word exist\r\n",
" else:\r\n",
" bag.append(0) #do not exist\r\n",
" \r\n",
" output_row = out_empty[:] #kopia\r\n",
" output_row[labels.index(docs_y[x])] = 1\r\n",
"\r\n",
" training.append(bag) #dodajemy nowe wyrażenie zamienione na ciąg binarny\r\n",
" output.append(output_row)\r\n",
"\r\n",
"training = np.array(training) #Zbiór treningowy\r\n",
"for x, doc in enumerate(docs_x): #Przejście przez wszystkie słowa\n",
" bag =[]\n",
"\n",
" wrds = [stemmer_pl.stem(w) for w in doc] #podział wszystkich słów w danym zdaniu\n",
"\n",
" for w in words:\n",
" if w in wrds:\n",
" bag.append(1) #this word exist\n",
" else:\n",
" bag.append(0) #do not exist\n",
" \n",
" output_row = out_empty[:] #kopia\n",
" output_row[labels.index(docs_y[x])] = 1\n",
"\n",
" training.append(bag) #dodajemy nowe wyrażenie zamienione na ciąg binarny\n",
" output.append(output_row)\n",
"\n",
"training = np.array(training) #Zbiór treningowy\n",
"output = np.array(output) #Zbiór outputów"
],
"execution_count": 16,
"outputs": []
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
@ -363,27 +330,14 @@
"id": "cJKUjbkC72-f",
"outputId": "7e2bff96-78ce-49ff-b27b-eee77752228d"
},
"outputs": [],
"source": [
"len(training) #dla pl_short mamy 44 słowa"
],
"execution_count": 18,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"44"
]
},
"metadata": {
"tags": []
},
"execution_count": 18
}
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
@ -391,23 +345,19 @@
"id": "Kx43VDgS7-yN",
"outputId": "4fa6f6fe-dc58-4e76-bb26-38c1784ab79c"
},
"outputs": [],
"source": [
"len(output[0]) #Które można przypisać do 4 kategorii"
],
"execution_count": 20,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"4"
]
},
"metadata": {
"tags": []
},
"execution_count": 20
}
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"print(training)\n",
"print(output)"
]
},
{
@ -421,15 +371,15 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "MDA435sI1-Xl"
},
"outputs": [],
"source": [
"training = np.array(training) #zamiana typu dla sieci neuronowej\r\n",
"training = np.array(training) #zamiana typu dla sieci neuronowej\n",
"output = np.array(output) #zamiana typu dla sieci neuronowej"
],
"execution_count": 22,
"outputs": []
]
},
{
"cell_type": "markdown",
@ -442,6 +392,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
@ -449,30 +400,19 @@
"id": "XaQJh1aG2hbj",
"outputId": "80420df0-3a78-4583-9563-2165e968713d"
},
"outputs": [],
"source": [
"tensorflow.compat.v1.reset_default_graph() #Reset na wszelki wypadek (w sumie nie wiem czy to jakaś super ważna linijka kodu)\r\n",
"\r\n",
"net = tflearn.input_data(shape=[None, len(training[0])]) #Input layer\r\n",
"net = tflearn.fully_connected(net, 8) #8 neurons for hidden layer\r\n",
"net = tflearn.fully_connected(net, 8) #8 neurons for hidden layer\r\n",
"#net = tflearn.fully_connected(net, 8) #8 neurons for hidden layer\r\n",
"net = tflearn.fully_connected(net, len(output[0]), activation=\"softmax\") #len(output) neurons for output layer + Softmax jako najlepsze wyjście dla tego typu danych\r\n",
"net = tflearn.regression(net)\r\n",
"\r\n",
"model = tflearn.DNN(net)\r\n",
"\r\n"
],
"execution_count": 23,
"outputs": [
{
"output_type": "stream",
"text": [
"WARNING:tensorflow:From /usr/local/lib/python3.7/dist-packages/tflearn/initializations.py:165: calling TruncatedNormal.__init__ (from tensorflow.python.ops.init_ops) with dtype is deprecated and will be removed in a future version.\n",
"Instructions for updating:\n",
"Call initializer instance with the dtype argument instead of passing it to the constructor\n"
],
"name": "stdout"
}
"tensorflow.compat.v1.reset_default_graph() #Reset na wszelki wypadek (w sumie nie wiem czy to jakaś super ważna linijka kodu)\n",
"\n",
"net = tflearn.input_data(shape=[None, len(training[0])]) #Input layer\n",
"net = tflearn.fully_connected(net, 8) #8 neurons for hidden layer\n",
"net = tflearn.fully_connected(net, 8) #8 neurons for hidden layer\n",
"#net = tflearn.fully_connected(net, 8) #8 neurons for hidden layer\n",
"net = tflearn.fully_connected(net, len(output[0]), activation=\"softmax\") #len(output) neurons for output layer + Softmax jako najlepsze wyjście dla tego typu danych\n",
"net = tflearn.regression(net)\n",
"\n",
"model = tflearn.DNN(net)\n",
"\n"
]
},
{
@ -486,6 +426,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
@ -493,25 +434,12 @@
"id": "REzkJL_r2hwl",
"outputId": "7ab2b0c5-944f-4e22-d478-1e35b41f87db"
},
"outputs": [],
"source": [
"model.fit(training, output, n_epoch=1000, batch_size=8, show_metric=True)\r\n",
"\r\n",
"#Zapis Modelu\r\n",
"model.fit(training, output, n_epoch=1000, batch_size=8, show_metric=True)\n",
"\n",
"#Zapis Modelu\n",
"#model.save(\"model.tflearn\")"
],
"execution_count": 24,
"outputs": [
{
"output_type": "stream",
"text": [
"Training Step: 5999 | total loss: \u001b[1m\u001b[32m0.46985\u001b[0m\u001b[0m | time: 0.036s\n",
"| Adam | epoch: 1000 | loss: 0.46985 - acc: 0.7877 -- iter: 40/44\n",
"Training Step: 6000 | total loss: \u001b[1m\u001b[32m0.47602\u001b[0m\u001b[0m | time: 0.046s\n",
"| Adam | epoch: 1000 | loss: 0.47602 - acc: 0.7839 -- iter: 44/44\n",
"--\n"
],
"name": "stdout"
}
]
},
{
@ -534,24 +462,24 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "1IQyV1v33lC7"
},
"outputs": [],
"source": [
"def bag_of_words(s, words):\r\n",
" bag = [0 for _ in range(len(words))]\r\n",
"\r\n",
" s_words = nltk.word_tokenize(s)\r\n",
" s_words = [stemmer_pl.stem(word.lower()) for word in s_words]\r\n",
"\r\n",
" for se in s_words:\r\n",
" for i, w in enumerate(words):\r\n",
" if w == se:\r\n",
" bag[i] = 1\r\n",
"def bag_of_words(s, words):\n",
" bag = [0 for _ in range(len(words))]\n",
"\n",
" s_words = nltk.word_tokenize(s)\n",
" s_words = [stemmer_pl.stem(word.lower()) for word in s_words]\n",
"\n",
" for se in s_words:\n",
" for i, w in enumerate(words):\n",
" if w == se:\n",
" bag[i] = 1\n",
" return np.array(bag)"
],
"execution_count": 26,
"outputs": []
]
},
{
"cell_type": "markdown",
@ -564,29 +492,29 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "Je6OSZ679-KL"
},
"outputs": [],
"source": [
"def chat():\r\n",
" print(\"Możesz rozpocząć rozmowę z Botem! (type quit to stop)\")\r\n",
" while True: #Ciągła rozmowa\r\n",
" inp = input(\"Ty: \")\r\n",
" if inp.lower() == \"quit\": #Quit by wyjść z loopa\r\n",
" break\r\n",
"\r\n",
" result = model.predict([bag_of_words(inp,words)]) #Predictowanie przy pomocy wyćwiczonego modelu\r\n",
" result_index = np.argmax(result)\r\n",
" tag = labels[result_index]\r\n",
" \r\n",
" for tg in data_pl_short[\"intents\"]: #znalezienie poprawnego tagu do zdania\r\n",
" if tg['tag'] == tag:\r\n",
" responses = tg['responses']\r\n",
" \r\n",
"def chat():\n",
" print(\"Możesz rozpocząć rozmowę z Botem! (type quit to stop)\")\n",
" while True: #Ciągła rozmowa\n",
" inp = input(\"Ty: \")\n",
" if inp.lower() == \"quit\": #Quit by wyjść z loopa\n",
" break\n",
"\n",
" result = model.predict([bag_of_words(inp,words)]) #Predictowanie przy pomocy wyćwiczonego modelu\n",
" result_index = np.argmax(result)\n",
" tag = labels[result_index]\n",
" \n",
" for tg in data_pl_short[\"intents\"]: #znalezienie poprawnego tagu do zdania\n",
" if tg['tag'] == tag:\n",
" responses = tg['responses']\n",
" \n",
" print(random.choice(responses)) #Wyprintuj losową odpowiedz z danego zbioru odpowiedzi"
],
"execution_count": 32,
"outputs": []
]
},
{
"cell_type": "markdown",
@ -599,6 +527,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
@ -606,30 +535,36 @@
"id": "VZf_aCUM-Amm",
"outputId": "9e3fcf7b-b9b3-47b0-acb5-48214f07f363"
},
"outputs": [],
"source": [
"chat()"
],
"execution_count": 33,
"outputs": [
{
"output_type": "stream",
"text": [
"Możesz rozpocząć rozmowę z Botem! (type quit to stop)\n",
"Ty: hej\n",
"Dobrze Cię widzieć!\n",
"Ty: ile masz lat?\n",
"Mam kilka dni\n",
"Ty: Kim jesteś?\n",
"Dobrze Cię widzieć!\n",
"Ty: Jak masz na imię?\n",
"Jestem Janet, twój ulubiony chatbot\n",
"Ty: Miłego Dnia\n",
"Do zobaczenia później\n",
"Ty: quit\n"
],
"name": "stdout"
}
]
}
]
],
"metadata": {
"colab": {
"name": "DL_Chatbot_ver_1_0.ipynb",
"provenance": [],
"toc_visible": true
},
"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.8.5"
}
},
"nbformat": 4,
"nbformat_minor": 1
}

View File

@ -1,32 +1,91 @@
{"intents": [
{"tag": "greeting",
"patterns": ["Hi", "How are you", "Is anyone there?", "Hello", "Good day", "Whats up"],
"responses": ["Hello!", "Good to see you again!", "Hi there, how can I help?"],
{
"intents": [
{
"tag": "greeting",
"patterns": [
"Hi",
"How are you",
"Is anyone there?",
"Hello",
"Good day",
"Whats up"
],
"responses": [
"Hello!",
"Good to see you again!",
"Hi there, how can I help?"
],
"context_set": ""
},
{"tag": "goodbye",
"patterns": ["cya", "See you later", "Goodbye", "I am Leaving", "Have a Good day"],
"responses": ["Sad to see you go :(", "Talk to you later", "Goodbye!"],
{
"tag": "goodbye",
"patterns": [
"cya",
"See you later",
"Goodbye",
"I am Leaving",
"Have a Good day"
],
"responses": [
"Sad to see you go :(",
"Talk to you later",
"Goodbye!"
],
"context_set": ""
},
{"tag": "age",
"patterns": ["how old", "how old is tim", "what is your age", "how old are you", "age?"],
"responses": ["I am 18 years old!", "18 years young!"],
{
"tag": "age",
"patterns": [
"how old",
"how old is tim",
"what is your age",
"how old are you",
"age?"
],
"responses": [
"I am 18 years old!",
"18 years young!"
],
"context_set": ""
},
{"tag": "name",
"patterns": ["what is your name", "what should I call you", "whats your name?"],
"responses": ["You can call me Tim.", "I'm Tim!", "I'm Tim aka Tech With Tim."],
{
"tag": "name",
"patterns": [
"what is your name",
"what should I call you",
"whats your name?"
],
"responses": [
"You can call me Tim.",
"I'm Tim!",
"I'm Tim aka Tech With Tim."
],
"context_set": ""
},
{"tag": "shop",
"patterns": ["Id like to buy something", "whats on the menu", "what do you reccommend?", "could i get something to eat"],
"responses": ["We sell chocolate chip cookies for $2!", "Cookies are on the menu!"],
{
"tag": "shop",
"patterns": [
"Id like to buy something",
"whats on the menu",
"what do you reccommend?",
"could i get something to eat"
],
"responses": [
"We sell chocolate chip cookies for $2!",
"Cookies are on the menu!"
],
"context_set": ""
},
{"tag": "hours",
"patterns": ["when are you guys open", "what are your hours", "hours of operation"],
"responses": ["We are open 7am-4pm Monday-Friday!"],
{
"tag": "hours",
"patterns": [
"when are you guys open",
"what are your hours",
"hours of operation"
],
"responses": [
"We are open 7am-4pm Monday-Friday!"
],
"context_set": ""
}
]

View File

@ -1,52 +1,156 @@
{"intents": [
{"tag": "greeting",
"patterns": ["Cześć", "Elo", "Jesteś?", "Hej", "Dzień dobry", "Sup"],
"responses": ["Cześć!", "Dobrze Cię widzieć!", "Hej, w czym mogę pomóc?"],
{
"intents": [
{
"tag": "greeting",
"patterns": [
"Cześć",
"Elo",
"Jesteś?",
"Hej",
"Dzień dobry",
"Sup"
],
"responses": [
"Cześć!",
"Dobrze Cię widzieć!",
"Hej, w czym mogę pomóc?"
],
"context_set": ""
},
{"tag": "goodbye",
"patterns": ["narazie", "Do zobaczenia", "Dowidzenia", "Dobranoc", "Miłego dnia"],
"responses": ["Do zobaczenia później", "Mam nadzieję, że później pogadamy", "Narazie!"],
{
"tag": "goodbye",
"patterns": [
"narazie",
"Do zobaczenia",
"Dowidzenia",
"Dobranoc",
"Miłego dnia"
],
"responses": [
"Do zobaczenia później",
"Mam nadzieję, że później pogadamy",
"Narazie!"
],
"context_set": ""
},
{"tag": "age",
"patterns": ["Ile masz lat", "Ile lat ma Janet", "Wiek", "Jak stara jesteś", "urodziny"],
"responses": ["Mam kilka dni", "Urodziłam się 17.03.2021"],
{
"tag": "age",
"patterns": [
"Ile masz lat",
"Ile lat ma Janet",
"Wiek",
"Jak stara jesteś",
"urodziny"
],
"responses": [
"Mam kilka dni",
"Urodziłam się 17.03.2021"
],
"context_set": ""
},
{"tag": "name",
"patterns": ["Jak masz na imię", "Jak Cię zwą?", "twoje imie?", "Imie", "Jak cię nazywać", "Kim jesteś"],
"responses": ["Możesz mnie nazywać Janet!", "Jestem Janet", "Jestem Janet, twój ulubiony chatbot"],
{
"tag": "name",
"patterns": [
"Jak masz na imię",
"Jak Cię zwą?",
"twoje imie?",
"Imie",
"Jak cię nazywać",
"Kim jesteś"
],
"responses": [
"Możesz mnie nazywać Janet!",
"Jestem Janet",
"Jestem Janet, twój ulubiony chatbot"
],
"context_set": ""
},
{"tag": "goout",
"patterns": ["Czy chcesz gdzieś wyjść?", "zrobimy coś razem?", "pójdziemy gdzieś razem?"],
"responses": ["Może kiedy indziej", "Odezwę się latem"],
{
"tag": "goout",
"patterns": [
"Czy chcesz gdzieś wyjść?",
"zrobimy coś razem?",
"pójdziemy gdzieś razem?"
],
"responses": [
"Może kiedy indziej",
"Odezwę się latem"
],
"context_set": ""
},
{"tag": "doing",
"patterns": ["Co robisz teraz?", "co słychać", "jakie masz plany?", "jak się masz?"],
"responses": ["Gram w grę", "Słucham muzyki", "nie twój interes", "nie mam czasu odpowiadać", ""],
{
"tag": "doing",
"patterns": [
"Co robisz teraz?",
"co słychać",
"jakie masz plany?",
"jak się masz?"
],
"responses": [
"Gram w grę",
"Słucham muzyki",
"nie twój interes",
"nie mam czasu odpowiadać",
""
],
"context_set": ""
},
{"tag": "game",
"patterns": ["a w co grasz?", "a w co?", "grasz?"],
"responses": ["nie interesuj się", "a co cię to obchodzi", "...", "w coś", "W OSRS"],
{
"tag": "game",
"patterns": [
"a w co grasz?",
"a w co?",
"grasz?"
],
"responses": [
"nie interesuj się",
"a co cię to obchodzi",
"...",
"w coś",
"W OSRS"
],
"context_set": ""
},
{"tag": "music",
"patterns": ["czego?", "czego słuchasz?", "jakiej muzyki?"],
"responses": ["Starego vinyla z 1995 roku", "mojego ulubionego setu rejwowego", "czegoś tam..."],
{
"tag": "music",
"patterns": [
"czego?",
"czego słuchasz?",
"jakiej muzyki?"
],
"responses": [
"Starego vinyla z 1995 roku",
"mojego ulubionego setu rejwowego",
"czegoś tam..."
],
"context_set": ""
},
{"tag": "angry",
"patterns": ["bo co?", "dlaczego?", "jak to?"],
"responses": ["Czas zakończyć rozmowę", "nie mam na to siły i czasu", "zostaw mnie w spokoju"],
{
"tag": "angry",
"patterns": [
"bo co?",
"dlaczego?",
"jak to?"
],
"responses": [
"Czas zakończyć rozmowę",
"nie mam na to siły i czasu",
"zostaw mnie w spokoju"
],
"context_set": ""
},
{"tag": "why",
"patterns": ["o co chodzi?", "czemu jesteś zła", "poczekaj"],
"responses": ["...", "Nie pisz do mnie więcej", "Odezwę się latem"],
{
"tag": "why",
"patterns": [
"o co chodzi?",
"czemu jesteś zła",
"poczekaj"
],
"responses": [
"...",
"Nie pisz do mnie więcej",
"Odezwę się latem"
],
"context_set": ""
}
]

View File

@ -1,22 +1,68 @@
{"intents": [
{"tag": "greeting",
"patterns": ["Cześć", "Elo", "Jesteś?", "Hej", "Dzień dobry", "Sup"],
"responses": ["Cześć!", "Dobrze Cię widzieć!", "Hej, w czym mogę pomóc?"],
{
"intents": [
{
"tag": "greeting",
"patterns": [
"Cześć",
"Elo",
"Jesteś?",
"Hej",
"Dzień dobry",
"Sup"
],
"responses": [
"Cześć!",
"Dobrze Cię widzieć!",
"Hej, w czym mogę pomóc?"
],
"context_set": ""
},
{"tag": "goodbye",
"patterns": ["narazie", "Do zobaczenia", "Dowidzenia", "Dobranoc", "Miłego dnia"],
"responses": ["Do zobaczenia później", "Mam nadzieję, że później pogadamy", "Narazie!"],
{
"tag": "goodbye",
"patterns": [
"narazie",
"Do zobaczenia",
"Dowidzenia",
"Dobranoc",
"Miłego dnia"
],
"responses": [
"Do zobaczenia później",
"Mam nadzieję, że później pogadamy",
"Narazie!"
],
"context_set": ""
},
{"tag": "age",
"patterns": ["Ile masz lat", "Ile lat ma Janet", "Wiek", "Jak stara jesteś", "urodziny"],
"responses": ["Mam kilka dni", "Urodziłam się 17.03.2021"],
{
"tag": "age",
"patterns": [
"Ile masz lat",
"Ile lat ma Janet",
"Wiek",
"Jak stara jesteś",
"urodziny"
],
"responses": [
"Mam kilka dni",
"Urodziłam się 17.03.2021"
],
"context_set": ""
},
{"tag": "name",
"patterns": ["Jak masz na imię", "Jak Cię zwą?", "twoje imie?", "Imie", "Jak cię nazywać", "Kim jesteś"],
"responses": ["Możesz mnie nazywać Janet!", "Jestem Janet", "Jestem Janet, twój ulubiony chatbot"],
{
"tag": "name",
"patterns": [
"Jak masz na imię",
"Jak Cię zwą?",
"twoje imie?",
"Imie",
"Jak cię nazywać",
"Kim jesteś"
],
"responses": [
"Możesz mnie nazywać Janet!",
"Jestem Janet",
"Jestem Janet, twój ulubiony chatbot"
],
"context_set": ""
}
]

3
requirements.txt Normal file
View File

@ -0,0 +1,3 @@
tflearn==0.5
tensorflow
pystempel==1.2