Compare commits
No commits in common. "master" and "dummy" have entirely different histories.
5
.gitignore
vendored
5
.gitignore
vendored
@ -1,5 +0,0 @@
|
||||
*frame-model*
|
||||
*slot-model*
|
||||
.venv*
|
||||
env*
|
||||
*__pycache__*
|
583
.ipynb_checkpoints/DL_Chatbot_ver_1_0-checkpoint.ipynb
Normal file
583
.ipynb_checkpoints/DL_Chatbot_ver_1_0-checkpoint.ipynb
Normal file
@ -0,0 +1,583 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "HxtCFj1hfXw6"
|
||||
},
|
||||
"source": [
|
||||
"# 0. Instalacja i importowanie modułów"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "enDE5aTIgN-v"
|
||||
},
|
||||
"source": [
|
||||
"##### 0.1. Ogólne"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "D7_8XDfpfH-X"
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Collecting tflearn==0.5 (from -r requirements.txt (line 1))\n",
|
||||
"\u001b[?25l Downloading https://files.pythonhosted.org/packages/e7/3c/0b156d08ef3d4e2a8009ecab2af1ad2e304f6fb99562b6271c68a74a4397/tflearn-0.5.0.tar.gz (107kB)\n",
|
||||
"\u001b[K |████████████████████████████████| 112kB 1.7MB/s eta 0:00:01\n",
|
||||
"\u001b[?25hCollecting tensorflow (from -r requirements.txt (line 2))\n",
|
||||
"\u001b[?25l Downloading https://files.pythonhosted.org/packages/70/dc/e8c5e7983866fa4ef3fd619faa35f660b95b01a2ab62b3884f038ccab542/tensorflow-2.4.1-cp37-cp37m-manylinux2010_x86_64.whl (394.3MB)\n",
|
||||
"\u001b[K |█████████████████████▍ | 263.6MB 2.0MB/s eta 0:01:06 |▉ | 10.3MB 2.0MB/s eta 0:03:11 |██ | 24.7MB 2.3MB/s eta 0:02:38 |██▏ | 26.4MB 2.1MB/s eta 0:02:59 |███▍ | 42.2MB 1.8MB/s eta 0:03:14 |█████████▊ | 120.4MB 2.7MB/s eta 0:01:42 |██████████▉ | 133.4MB 2.4MB/s eta 0:01:49 |███████████████▍ | 190.0MB 3.0MB/s eta 0:01:08 |█████████████████ | 209.0MB 2.5MB/s eta 0:01:15 |██████████████████▌ | 227.7MB 2.8MB/s eta 0:01:00 |██████████████████▉ | 232.4MB 2.6MB/s eta 0:01:03 |███████████████████▊ | 242.5MB 3.2MB/s eta 0:00:47 |███████████████████▊ | 242.9MB 3.2MB/s eta 0:00:47"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"!pip install -r requirements.txt --user\n",
|
||||
"!pip list"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "GOGs4hL6fwwK"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import numpy as np\n",
|
||||
"import tflearn\n",
|
||||
"import tensorflow\n",
|
||||
"import random\n",
|
||||
"import json"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "Mr0ZD1L2gCWw"
|
||||
},
|
||||
"source": [
|
||||
"##### 0.2. Angielski Stemmer: https://www.nltk.org/_modules/nltk/stem/lancaster.html"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "jy4-9guXgBY3"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import nltk\n",
|
||||
"\n",
|
||||
"nltk.download('punkt')\n",
|
||||
"from nltk.stem.lancaster import LancasterStemmer\n",
|
||||
"stemmer_en = LancasterStemmer()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "uPpcNQa_ggUl"
|
||||
},
|
||||
"source": [
|
||||
"##### 0.3. Polski Stemmer **(Docelowy)**: https://pypi.org/project/pystempel/"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "XBpvJXn1gBDi"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from stempel import StempelStemmer\n",
|
||||
"\n",
|
||||
"stemmer_pl = StempelStemmer.default() #może wersja \".polimorf()\" jest lepsza?"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "Lg_3MO_3hQV_"
|
||||
},
|
||||
"source": [
|
||||
"# 1. Załadowanie plików **.json** z bazą słów"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "BzBo1657hn3w"
|
||||
},
|
||||
"source": [
|
||||
"##### 1.1. Docelowa baza słów polskich do nauki modelu (10 rodzajów odp - PL)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/"
|
||||
},
|
||||
"id": "jKsIW7hHhepB",
|
||||
"outputId": "09ba1cb1-bb0e-44ee-9d28-017209902934"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"with open(\"intents_pl.json\", encoding='utf-8') as file:\n",
|
||||
" data_pl = json.load(file)\n",
|
||||
"\n",
|
||||
"print(data_pl)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "g94eHpqshoat"
|
||||
},
|
||||
"source": [
|
||||
"##### 1.2. Skrócona baza słów (4 rodzaje odp - PL)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/"
|
||||
},
|
||||
"id": "gJbm_CtRhNOK",
|
||||
"outputId": "157196fc-6a25-4a70-aca3-9d886c743f6c"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"with open(\"intents_pl_short.json\", encoding='utf-8') as file:\n",
|
||||
" data_pl_short = json.load(file)\n",
|
||||
"\n",
|
||||
"print(data_pl_short)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "HjkIUMy2ho6C"
|
||||
},
|
||||
"source": [
|
||||
"##### 1.3. Testowa baza słów angielskich (6 rodzajów odp - EN)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/"
|
||||
},
|
||||
"id": "vW5FyoRqhfIc",
|
||||
"outputId": "378d8894-9c9c-46be-ade1-b6491f095179"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"with open(\"intents_en.json\", encoding='utf-8') as file:\n",
|
||||
" data_en = json.load(file)\n",
|
||||
"\n",
|
||||
"print(data_en)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "4BnsOkqqjBlr"
|
||||
},
|
||||
"source": [
|
||||
"# 2. Przygotowanie danych do nauki modelu"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "gy6p55-DjLyY"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"words = []\n",
|
||||
"labels = []\n",
|
||||
"docs_x = []\n",
|
||||
"docs_y = []"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "XxZX-JQA5zjL"
|
||||
},
|
||||
"source": [
|
||||
"##### 2.1 Stworzenie tablicy ze wszystkimi możliwymi inputami użytkownika (+ labele)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "nBUKwSr_kVSd"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"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"
|
||||
]
|
||||
},
|
||||
{
|
||||
"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\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))]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"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",
|
||||
"metadata": {
|
||||
"id": "WewUeunf5_Za"
|
||||
},
|
||||
"source": [
|
||||
"##### 3.2. Przypisywanie słów do danej kategorii (ie. \"Cześć\" do Greetings)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "1Q43_qtZ6KNP"
|
||||
},
|
||||
"source": [
|
||||
"W przypadku data_pl_short są tylko 4 rodzaje odpowiedzi. \"Cześć\" które zostane przypisane do labela \"greeting\" będzie miało formę końcowego outputu \"1000\" jeżeli label \"greetings\" jest pierwszy do wyboru."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "doFER5OS7CC_"
|
||||
},
|
||||
"source": [
|
||||
"Warto też dodać, że sieć neuronowa nie przyjmuje teksu. To jest główny powód czemu przypisujemy słowa do kategorii"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "8FDKrjpjkYsE"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"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"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/"
|
||||
},
|
||||
"id": "cJKUjbkC72-f",
|
||||
"outputId": "7e2bff96-78ce-49ff-b27b-eee77752228d"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"len(training) #dla pl_short mamy 44 słowa"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/"
|
||||
},
|
||||
"id": "Kx43VDgS7-yN",
|
||||
"outputId": "4fa6f6fe-dc58-4e76-bb26-38c1784ab79c"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"len(output[0]) #Które można przypisać do 4 kategorii"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"print(training)\n",
|
||||
"print(output)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "yCFKTbjZ12wh"
|
||||
},
|
||||
"source": [
|
||||
"# 3. Model i jego ćwiczenie"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "MDA435sI1-Xl"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"training = np.array(training) #zamiana typu dla sieci neuronowej\n",
|
||||
"output = np.array(output) #zamiana typu dla sieci neuronowej"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "SvBURQCc3PBj"
|
||||
},
|
||||
"source": [
|
||||
"##### 3.1. Stworzenie DLN i inicjacja modelu"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/"
|
||||
},
|
||||
"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)\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"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "Ktd1OcBa3PmQ"
|
||||
},
|
||||
"source": [
|
||||
"##### 3.2. Trening Modelu"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/"
|
||||
},
|
||||
"id": "REzkJL_r2hwl",
|
||||
"outputId": "7ab2b0c5-944f-4e22-d478-1e35b41f87db"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"model.fit(training, output, n_epoch=1000, batch_size=8, show_metric=True)\n",
|
||||
"\n",
|
||||
"#Zapis Modelu\n",
|
||||
"#model.save(\"model.tflearn\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "G-L6TV_63iYs"
|
||||
},
|
||||
"source": [
|
||||
"# 4. Input Użytkownika"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "c6UvIrWu-a38"
|
||||
},
|
||||
"source": [
|
||||
"##### 4.1 Funkcja **\"bag_of_words(s, words)\"** do stemmowania twojego zdania, i przypisania mu formy binarnej"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "1IQyV1v33lC7"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"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)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "rXq-wj-F-5DE"
|
||||
},
|
||||
"source": [
|
||||
"##### 4.2 Funkcja **\"chat()\"** do rozmowy z botem"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"id": "Je6OSZ679-KL"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"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"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"id": "ifvjglbO_SEA"
|
||||
},
|
||||
"source": [
|
||||
"# 5. Rozmowa z botem!"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"colab": {
|
||||
"base_uri": "https://localhost:8080/"
|
||||
},
|
||||
"id": "VZf_aCUM-Amm",
|
||||
"outputId": "9e3fcf7b-b9b3-47b0-acb5-48214f07f363"
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"chat()"
|
||||
]
|
||||
}
|
||||
],
|
||||
"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.7.3"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 1
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
import pandas as pd
|
||||
import numpy as np
|
||||
|
||||
file1 = open('Janet.conllu', 'r')
|
||||
Lines = file1.readlines()
|
||||
|
||||
texts = []
|
||||
intents = []
|
||||
|
||||
count = 0
|
||||
# Strips the newline character
|
||||
for line in Lines:
|
||||
count += 1
|
||||
if(line.startswith('# text')):
|
||||
p_line = line.strip()
|
||||
print("Line{}: {}".format(count, p_line[8:]))
|
||||
texts.append(p_line[8:])
|
||||
|
||||
if(line.startswith('# intent')):
|
||||
x_line = line.strip()
|
||||
print("Line{}: {}".format(count, x_line[10:]))
|
||||
intents.append(x_line[10:])
|
||||
|
||||
data = {'Text':texts, 'Intent':intents}
|
||||
df = pd.DataFrame(data)
|
||||
|
||||
print(df.head(5))
|
||||
|
||||
df.to_csv(r'data.tsv',index=False, sep='\t')
|
@ -1,43 +0,0 @@
|
||||
#import jsgf
|
||||
|
||||
from Modules.NLG_module import NLG
|
||||
from Modules.DP_module import DP
|
||||
from Modules.DST_module import Rules_DST
|
||||
# from Modules.Book_NLU_module import Book_NLU
|
||||
from Modules.ML_NLU_module import ML_NLU
|
||||
|
||||
import random
|
||||
import torch
|
||||
random.seed(42)
|
||||
torch.manual_seed(42)
|
||||
|
||||
if torch.cuda.is_available():
|
||||
torch.cuda.manual_seed(0)
|
||||
torch.cuda.manual_seed_all(0)
|
||||
torch.backends.cudnn.enabled = False
|
||||
torch.backends.cudnn.benchmark = False
|
||||
torch.backends.cudnn.deterministic = True
|
||||
|
||||
class Janet:
|
||||
def __init__(self):
|
||||
self.nlg = NLG()
|
||||
self.dp = DP()
|
||||
self.dst = Rules_DST()
|
||||
#self.nlu = Book_NLU(jsgf.parse_grammar_file('book.jsgf'))
|
||||
self.nlu_v2 = ML_NLU()
|
||||
|
||||
def process(self, command):
|
||||
act = self.nlu_v2.test_nlu(command)
|
||||
system_acts = self.dp.predict(self.dst.update_user(act))
|
||||
return self.nlg.change_to_text(system_acts)
|
||||
|
||||
|
||||
def main():
|
||||
janet = Janet()
|
||||
while(1):
|
||||
print('\n')
|
||||
text = input("Wpisz tekst: ")
|
||||
print(janet.process(text))
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
@ -1,51 +0,0 @@
|
||||
import jsgf
|
||||
|
||||
class Book_NLU: #Natural Language Understanding
|
||||
"""
|
||||
Moduł odpowiedzialny za analizę tekstu. W wyniku jego działania tekstowa reprezentacja wypowiedzi użytkownika zostaje zamieniona na jej reprezentację semantyczną, najczęściej w postaci ramy.
|
||||
|
||||
Wejście: Tekst
|
||||
|
||||
Wyjście: Akt użytkownika (rama)
|
||||
"""
|
||||
def __init__(self, book_grammar):
|
||||
self.book_grammar = book_grammar
|
||||
|
||||
def get_dialog_act(self, rule):
|
||||
slots = []
|
||||
self.get_slots(rule.expansion, slots)
|
||||
return {'act': rule.grammar.name, 'slots': slots}
|
||||
|
||||
def get_slots(self, expansion, slots):
|
||||
if expansion.tag != '':
|
||||
slots.append((expansion.tag, expansion.current_match))
|
||||
return
|
||||
|
||||
for child in expansion.children:
|
||||
self.get_slots(child, slots)
|
||||
|
||||
if not expansion.children and isinstance(expansion, jsgf.NamedRuleRef):
|
||||
self.get_slots(expansion.referenced_rule.expansion, slots)
|
||||
|
||||
def analyze(self, text):
|
||||
"""
|
||||
Analiza Tekstu wprowadzonego przez użytkownika i zamiana na akt (rama)
|
||||
"""
|
||||
print("Analiza Tekstu: " + text)
|
||||
act = "(greetings()&request(name))"
|
||||
print("Akt to: " + act)
|
||||
#przerobienie na wektor
|
||||
act_vector = [[0],[1,0]] #1 wektor to greetings, a 2 wektor to request z argumentem "name"
|
||||
print("Zamiana na: ")
|
||||
print(act_vector)
|
||||
return act_vector
|
||||
|
||||
def test_nlu(self, utterance):
|
||||
matched = self.book_grammar.find_matching_rules(utterance)
|
||||
print(matched)
|
||||
|
||||
if matched:
|
||||
return self.get_dialog_act(matched[0])
|
||||
|
||||
else:
|
||||
return {'act': 'null', 'slots': []}
|
@ -1,122 +0,0 @@
|
||||
from collections import defaultdict
|
||||
|
||||
class DP():
|
||||
"""
|
||||
Moduł decydujący o wyborze kolejnego aktu, który ma podjąć system prowadząc rozmowę.
|
||||
|
||||
Wejście: Reprezentacja stanu dialogu (rama)
|
||||
|
||||
Wyjście: Akt systemu (rama)
|
||||
"""
|
||||
|
||||
|
||||
def predict(self, state):
|
||||
self.results = []
|
||||
system_action = defaultdict(dict)
|
||||
user_action = defaultdict(list)
|
||||
system_acts = []
|
||||
while len(state['user_action']) > 0:
|
||||
intent, domain, slot, value = state['user_action'].pop(0)
|
||||
user_action[(domain, intent)].append((slot, value))
|
||||
|
||||
for user_act in user_action:
|
||||
system_acts.append(self.update_system_action(user_act, user_action, state, system_action))
|
||||
|
||||
state['system_action'] = system_acts
|
||||
print(state)
|
||||
print("\n")
|
||||
return system_acts
|
||||
|
||||
|
||||
# # Reguła 3
|
||||
# if any(True for slots in user_action.values() for (slot, _) in slots if slot in ['Stay', 'Day', 'People']):
|
||||
# if self.results:
|
||||
# system_action = {('Booking', 'Book'): [["Ref", self.results[0].get('Ref', 'N/A')]]}
|
||||
|
||||
# system_acts = [[intent, domain, slot, value] for (domain, intent), slots in system_action.items() for slot, value in slots]
|
||||
# state['system_action'] = system_acts
|
||||
# return system_acts
|
||||
|
||||
def update_system_action(self, user_act, user_action, state, system_action):
|
||||
domain, intent = user_act
|
||||
|
||||
# Reguła 1
|
||||
|
||||
if domain == 'appointment':
|
||||
constraints = [(slot, value) for slot, value in state['belief_state'][domain.lower()].items() if value != '']
|
||||
if len(constraints) == 0:
|
||||
system_action[(domain, 'NoOffer')] = []
|
||||
elif intent == 'appointment/create_appointment':
|
||||
for x in constraints:
|
||||
if(x[0] == 'doctor'):
|
||||
system_action[(domain, 'book_appointent')][x[0]] = x[1]
|
||||
for y in constraints:
|
||||
if(y[0] == 'datetime'):
|
||||
system_action[(domain, 'book_appointent')][y[0]] = y[1]
|
||||
elif intent == 'appointment/set_date':
|
||||
for y in constraints:
|
||||
if(y[0] == 'datetime'):
|
||||
system_action[(domain, 'set_appointment_date')][y[0]] = y[1]
|
||||
|
||||
|
||||
|
||||
#################################################################################################
|
||||
# Reguła 2
|
||||
|
||||
if domain == 'request_information':
|
||||
constraints_v2 = [(slot, value) for slot, value in state['request_state'][domain.lower()].items() if value != '']
|
||||
if intent == 'request_information/available_dates':
|
||||
for x in constraints_v2:
|
||||
if(x[0] == 'doctor'):
|
||||
system_action[(domain, 'date_info')][x[0]] = x[1]
|
||||
for y in constraints_v2:
|
||||
if(y[0] == 'datetime'):
|
||||
system_action[(domain, 'date_info')][y[0]] = y[1]
|
||||
elif intent == 'request_information/doctors':
|
||||
system_action[("inform", 'Doctors_list')] = {"doctors": "dr. Kolano - okulista, dr. Kowalski - internista, dr. Kaszak - ginekolog"}
|
||||
elif intent == 'request_information/location':
|
||||
system_action[("inform", 'Location')] = {"street": "Marszałkowska", "number": "45", "city": "Poznań"}
|
||||
elif intent == 'request_information/cost':
|
||||
system_action[("inform", 'Cost')] = {"cost": "100 zł"}
|
||||
elif intent == 'request_information/opening_hours':
|
||||
system_action[("inform", 'Opening_Hours')] = {"hours": "'8:00 - 16:00"}
|
||||
elif intent == 'request_information/medical_services':
|
||||
system_action[("inform", 'Medical_services')] = {"services": "Okulista, Internista, Ginekolog"}
|
||||
elif len(constraints) == 0:
|
||||
system_action[("inform", 'NoOffer')] = {'0': '0'}
|
||||
|
||||
#################################################################################################
|
||||
# Reguła 3
|
||||
if domain == 'end_conversation':
|
||||
system_action[(domain, 'End_Conversation')] = {'0': '0'}
|
||||
|
||||
#################################################################################################
|
||||
# Reguła 4
|
||||
if domain == 'greeting':
|
||||
system_action[(domain, 'Greeting')] = {'0': '0'}
|
||||
|
||||
#################################################################################################
|
||||
# Reguła 5
|
||||
if domain == 'prescription':
|
||||
constraints_v2 = [(slot, value) for slot, value in state['request_state'][domain.lower()].items() if value != '']
|
||||
if intent == 'prescription/request':
|
||||
for x in constraints_v2:
|
||||
if(x[0] == 'prescription/type'):
|
||||
system_action[(domain, 'create_prescription')][x[0]] = x[1]
|
||||
for y in constraints_v2:
|
||||
if(y[0] == 'prescription/medicine'):
|
||||
system_action[(domain, 'create_prescription')][y[0]] = y[1]
|
||||
elif intent == 'prescription/collect':
|
||||
for x in constraints_v2:
|
||||
if(x[0] == 'prescription/type'):
|
||||
system_action[(domain, 'collect_prescription')][x[0]] = x[1]
|
||||
elif intent == 'prescription/type':
|
||||
for x in constraints_v2:
|
||||
if(x[0] == 'prescription/type_info'):
|
||||
system_action[(domain, 'prescription type')][x[0]] = x[1]
|
||||
if len(constraints_v2) == 0:
|
||||
system_action[(domain, 'NoOffer')] = []
|
||||
|
||||
return system_action
|
||||
|
||||
## Brakuje: Rejestracja, Login, Hasło, affirm, deny
|
@ -1,57 +0,0 @@
|
||||
import json
|
||||
|
||||
class Rules_DST(): #Dialogue State Tracker
|
||||
"""
|
||||
Moduł odpowiedzialny za śledzenie stanu dialogu. Przechowuje informacje o tym jakie dane zostały uzyskane od użytkownika w toku prowadzonej konwersacji.
|
||||
|
||||
Wejście: Akt użytkownika (rama)
|
||||
|
||||
Wyjście: Reprezentacja stanu dialogu (rama)
|
||||
"""
|
||||
def __init__(self):
|
||||
self.state = json.load(open('default_state.json'))
|
||||
|
||||
def update_user(self, user_acts=None):
|
||||
for intent, domain, slot, value in user_acts:
|
||||
self.state["user_action"].append([intent, domain, slot, value])
|
||||
if domain in ['password', 'name', 'email', 'enter_email', 'enter_name']:
|
||||
return
|
||||
|
||||
if 'appointment' in intent:
|
||||
if (slot == 'appointment'):
|
||||
continue
|
||||
|
||||
if(domain in slot):
|
||||
slot.replace(domain + "/", '')
|
||||
|
||||
domain_dic = self.state['belief_state'][domain]
|
||||
if slot in domain_dic:
|
||||
self.state['belief_state'][domain][slot] = value
|
||||
|
||||
if 'prescription' in intent:
|
||||
if (slot == 'prescription'):
|
||||
continue
|
||||
|
||||
if(domain in slot):
|
||||
slot.replace(domain + "/", '')
|
||||
|
||||
if domain not in self.state['request_state']:
|
||||
self.state['request_state'][domain] = {}
|
||||
if slot not in self.state['request_state'][domain]:
|
||||
self.state['request_state'][domain][slot] = value
|
||||
|
||||
if 'request_information' in intent:
|
||||
if (slot == 'request_information'):
|
||||
continue
|
||||
|
||||
if(domain in slot):
|
||||
slot.replace(domain + "/", '')
|
||||
|
||||
if domain not in self.state['request_state']:
|
||||
self.state['request_state'][domain] = {}
|
||||
if slot not in self.state['request_state'][domain]:
|
||||
self.state['request_state'][domain][slot] = value
|
||||
|
||||
elif intent == 'end_conversation':
|
||||
self.state = json.load(open('default_state.json'))
|
||||
return self.state
|
@ -1,75 +0,0 @@
|
||||
from flair.data import Sentence, Token
|
||||
from flair.datasets import SentenceDataset
|
||||
from flair.models import SequenceTagger
|
||||
|
||||
class ML_NLU:
|
||||
def __init__(self):
|
||||
self.slot_model, self.frame_model = self.setup()
|
||||
|
||||
def nolabel2o(self, line, i):
|
||||
return 'O' if line[i] == 'NoLabel' else line[i]
|
||||
|
||||
def conllu2flair(self, sentences, label=None):
|
||||
fsentences = []
|
||||
for sentence in sentences:
|
||||
fsentence = Sentence()
|
||||
for token in sentence:
|
||||
ftoken = Token(token['form'])
|
||||
if label:
|
||||
ftoken.add_tag(label, token[label])
|
||||
fsentence.add_token(ftoken)
|
||||
fsentences.append(fsentence)
|
||||
return SentenceDataset(fsentences)
|
||||
|
||||
|
||||
def predict(self, sentence):
|
||||
csentence = [{'form': word} for word in sentence]
|
||||
fsentence = self.conllu2flair([csentence])[0]
|
||||
self.slot_model.predict(fsentence)
|
||||
self.frame_model.predict(fsentence)
|
||||
possible_intents = {}
|
||||
for token in fsentence:
|
||||
for intent in token.annotation_layers["frame"]:
|
||||
if(intent.value in possible_intents):
|
||||
possible_intents[intent.value] += intent.score
|
||||
else:
|
||||
possible_intents[intent.value] = intent.score
|
||||
return [(token, ftoken.get_tag('slot').value) for token, ftoken in zip(sentence, fsentence)], max(possible_intents)
|
||||
|
||||
def setup(self):
|
||||
slot_model = SequenceTagger.load('slot-model/final-model.pt')
|
||||
frame_model = SequenceTagger.load('frame-model/final-model.pt')
|
||||
return slot_model, frame_model
|
||||
|
||||
def test_nlu(self, utterance):
|
||||
if utterance:
|
||||
slots, act = self.predict(utterance.split())
|
||||
slots = [x for x in slots if x[1] != 'O']
|
||||
arguments = self.convert_slot_to_argument(slots)
|
||||
return self.convert_act_to_list(act, arguments)
|
||||
else:
|
||||
return 'Critical Error'
|
||||
|
||||
def convert_slot_to_argument(self, slots):
|
||||
arguments = []
|
||||
candidate = None
|
||||
for slot in slots:
|
||||
if slot[1].startswith("B-"):
|
||||
if(candidate != None):
|
||||
arguments.append(candidate)
|
||||
candidate = [slot[1].replace("B-", ""), slot[0]]
|
||||
if slot[1].startswith("I-") and candidate != None and slot[1].endswith(candidate[0]):
|
||||
candidate[1] += " " + slot[0]
|
||||
if(candidate != None):
|
||||
arguments.append(candidate)
|
||||
return [(x[0], x[1]) for x in arguments]
|
||||
|
||||
def convert_act_to_list(self, act, slots):
|
||||
result = []
|
||||
for i in range(len(slots)):
|
||||
intent = act
|
||||
domain = act.split('/')[0]
|
||||
slot = slots[i][0]
|
||||
value = slots[i][1]
|
||||
result.append([intent, domain, slot, value])
|
||||
return result
|
@ -1,76 +0,0 @@
|
||||
import random
|
||||
import uuid
|
||||
|
||||
class NLG:
|
||||
"""
|
||||
Moduł, który tworzy reprezentację tekstową aktu systemowego wybranego przez taktykę dialogu.
|
||||
|
||||
Wejście: Akt systemu (rama)
|
||||
|
||||
Wyjście: Tekst
|
||||
"""
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def change_to_text(self, system_acts):
|
||||
"""
|
||||
Funkcja zamieniająca akt systemu na tekst rozumiany przez użytkownika.
|
||||
"""
|
||||
if(len(system_acts) == 0):
|
||||
return "Nie mam już nic do powiedzenia :("
|
||||
|
||||
act = system_acts.pop(0)
|
||||
if(len(act) == 0):
|
||||
return "Nie mam już nic do powiedzenia :("
|
||||
|
||||
for action in act:
|
||||
domain, intent = action
|
||||
if(domain == "greeting"):
|
||||
return random.choice(["Cześć, mam na imię Janet", "Hej, jestem Janet. W czym mogę pomóc?", "Dzień dobry, nazywam się Janet"])
|
||||
|
||||
if(domain == "end_conversation"):
|
||||
return random.choice(["Dziękujemy za skorzystanie z naszych usług!", "Do widzenia!", "Do zobaczenia!"])
|
||||
|
||||
if(domain == "appointment"):
|
||||
if (intent == "NoOffer"):
|
||||
return "Proszę sprecyzować zapis na wizytę (lekarz, godzina)"
|
||||
if (intent == "book_appointent"):
|
||||
answer = "Zarezerwowano wizytę"
|
||||
for key in act[action]:
|
||||
value = act[action][key]
|
||||
if(key == "doctor"):
|
||||
answer += f" do lekarza {value}"
|
||||
if(key== "datetime"):
|
||||
answer += f" umówiona na: {value}"
|
||||
return answer
|
||||
if (intent == "set_appointment_date"):
|
||||
value = act[action]["datetime"]
|
||||
return f"Ustawiono datę wizyty na {value}"
|
||||
|
||||
if(domain == "inform"):
|
||||
if (intent == "Doctors_list"):
|
||||
value = act[action]["doctors"]
|
||||
return f"Lista doktorów w naszej placówce: \n{value}"
|
||||
if (intent == "Medical_services"):
|
||||
value = act[action]["services"]
|
||||
return f"Lista usług oferowanych w naszej placówce: \n{value}"
|
||||
if (intent == "Location"):
|
||||
city = act[action]["city"]
|
||||
street = act[action]["street"]
|
||||
number = act[action]["number"]
|
||||
return f"Placówka znajduje się w {city}, {street} {number}"
|
||||
if (intent == "Opening_Hours"):
|
||||
value = act[action]["hours"]
|
||||
return f"Placówka jest otwarta w godzinach {value}"
|
||||
if (intent == "NoOffer"):
|
||||
return f"Nie posiadam takiej wiedzy, żeby odpowiedzieć na to pytanie :("
|
||||
|
||||
if(domain == "prescription"):
|
||||
if(intent == "create_prescription" or intent == "collect_prescription"):
|
||||
answer = f"Odebrano receptę {uuid.uuid4().hex}"
|
||||
return answer
|
||||
if(intent == "prescription type"):
|
||||
return "Wszystkie recepty w naszej placówce są elektroniczne"
|
||||
if (intent == "NoOffer"):
|
||||
return f"Nie rozumiem :("
|
||||
|
@ -1,36 +0,0 @@
|
||||
import jsgf
|
||||
|
||||
book_grammar = jsgf.parse_grammar_file('test_book.jsgf')
|
||||
book_grammar
|
||||
|
||||
utterance = 'chciałbym zarezerwować stolik na jutro na godzinę dwunastą trzydzieści na cztery osoby'
|
||||
matched = book_grammar.find_matching_rules(utterance)
|
||||
matched
|
||||
|
||||
def get_dialog_act(rule):
|
||||
slots = []
|
||||
get_slots(rule.expansion, slots)
|
||||
return {'act': rule.grammar.name, 'slots': slots}
|
||||
|
||||
def get_slots(expansion, slots):
|
||||
if expansion.tag != '':
|
||||
slots.append((expansion.tag, expansion.current_match))
|
||||
return
|
||||
|
||||
for child in expansion.children:
|
||||
get_slots(child, slots)
|
||||
|
||||
if not expansion.children and isinstance(expansion, jsgf.NamedRuleRef):
|
||||
get_slots(expansion.referenced_rule.expansion, slots)
|
||||
|
||||
get_dialog_act(matched[0])
|
||||
|
||||
def nlu(utterance):
|
||||
matched = book_grammar.find_matching_rules(utterance)
|
||||
|
||||
if matched:
|
||||
return get_dialog_act(matched[0])
|
||||
else:
|
||||
return {'act': 'null', 'slots': []}
|
||||
|
||||
print(nlu('chciałbym zarezerwować stolik na jutro na godzinę dziesiątą dla trzech osób'))
|
48
Code/eval.py
48
Code/eval.py
@ -1,48 +0,0 @@
|
||||
import pandas as pd
|
||||
from tabulate import tabulate
|
||||
from flair.data import Sentence, Token
|
||||
from flair.datasets import SentenceDataset
|
||||
from flair.models import SequenceTagger
|
||||
|
||||
def conllu2flair(sentences, label=None):
|
||||
fsentences = []
|
||||
for sentence in sentences:
|
||||
fsentence = Sentence()
|
||||
for token in sentence:
|
||||
ftoken = Token(token['form'])
|
||||
if label:
|
||||
ftoken.add_tag(label, token[label])
|
||||
fsentence.add_token(ftoken)
|
||||
fsentences.append(fsentence)
|
||||
return SentenceDataset(fsentences)
|
||||
|
||||
def predict(frame_model, sentence):
|
||||
csentence = [{'form': word} for word in sentence]
|
||||
fsentence = conllu2flair([csentence])[0]
|
||||
frame_model.predict(fsentence)
|
||||
possible_intents = {}
|
||||
for token in fsentence:
|
||||
for intent in token.annotation_layers["frame"]:
|
||||
if(intent.value in possible_intents):
|
||||
possible_intents[intent.value] += intent.score
|
||||
else:
|
||||
possible_intents[intent.value] = intent.score
|
||||
return max(possible_intents)
|
||||
|
||||
frame_model = SequenceTagger.load('frame-model/final-model.pt')
|
||||
data = []
|
||||
with open('data.tsv') as f:
|
||||
lines = f.readlines()
|
||||
|
||||
for line in lines[1:]:
|
||||
data.append((line.split("\t")[0], line.split("\t")[1]))
|
||||
|
||||
correct = 0
|
||||
for sentence in data:
|
||||
predicted_intent = predict(frame_model, sentence[0].split())
|
||||
if predicted_intent == sentence[1].replace('\n',''):
|
||||
correct+=1
|
||||
else:
|
||||
print(predicted_intent + " != " + sentence[1].replace('\n',''))
|
||||
|
||||
print(f"{correct/len(data)} {correct}/{len(data)}")
|
@ -1,81 +0,0 @@
|
||||
from conllu import parse_incr
|
||||
from tabulate import tabulate
|
||||
from flair.data import Corpus, Sentence, Token
|
||||
from flair.datasets import SentenceDataset
|
||||
from flair.embeddings import StackedEmbeddings
|
||||
from flair.embeddings import WordEmbeddings
|
||||
from flair.embeddings import CharacterEmbeddings
|
||||
from flair.embeddings import FlairEmbeddings
|
||||
from flair.models import SequenceTagger
|
||||
from flair.trainers import ModelTrainer
|
||||
|
||||
def nolabel2o(line, i):
|
||||
return 'O' if line[i] == 'NoLabel' else line[i]
|
||||
|
||||
def conllu2flair(sentences, label=None):
|
||||
fsentences = []
|
||||
|
||||
for sentence in sentences:
|
||||
fsentence = Sentence()
|
||||
|
||||
for token in sentence:
|
||||
ftoken = Token(token['form'])
|
||||
|
||||
if label:
|
||||
ftoken.add_tag(label, token[label])
|
||||
|
||||
fsentence.add_token(ftoken)
|
||||
|
||||
fsentences.append(fsentence)
|
||||
|
||||
return SentenceDataset(fsentences)
|
||||
|
||||
fields = ['id', 'form', 'frame', 'slot']
|
||||
|
||||
with open('Janet.conllu', encoding='utf-8') as trainfile:
|
||||
slot_trainset = list(parse_incr(trainfile, fields=fields, field_parsers={'slot': nolabel2o}))
|
||||
with open('Janet.conllu', encoding='utf-8') as trainfile:
|
||||
frame_trainset = list(parse_incr(trainfile, fields=fields, field_parsers={'frame': nolabel2o}))
|
||||
|
||||
tabulate(slot_trainset[0], tablefmt='html')
|
||||
|
||||
|
||||
slot_corpus = Corpus(train=conllu2flair(slot_trainset, 'slot'), test=conllu2flair(slot_trainset, 'slot'))
|
||||
frame_corpus = Corpus(train=conllu2flair(frame_trainset, 'frame'), test=conllu2flair(frame_trainset, 'frame'))
|
||||
|
||||
slot_tag_dictionary = slot_corpus.make_tag_dictionary(tag_type='slot')
|
||||
frame_tag_dictionary = frame_corpus.make_tag_dictionary(tag_type='frame')
|
||||
|
||||
print(slot_tag_dictionary)
|
||||
print(frame_tag_dictionary)
|
||||
|
||||
|
||||
embedding_types = [
|
||||
WordEmbeddings('pl'),
|
||||
FlairEmbeddings('pl-forward'),
|
||||
FlairEmbeddings('pl-backward'),
|
||||
CharacterEmbeddings(),
|
||||
]
|
||||
|
||||
embeddings = StackedEmbeddings(embeddings=embedding_types)
|
||||
slot_tagger = SequenceTagger(hidden_size=256, embeddings=embeddings,
|
||||
tag_dictionary=slot_tag_dictionary,
|
||||
tag_type='slot', use_crf=True)
|
||||
frame_tagger = SequenceTagger(hidden_size=256, embeddings=embeddings,
|
||||
tag_dictionary=frame_tag_dictionary,
|
||||
tag_type='frame', use_crf=True)
|
||||
|
||||
slot_trainer = ModelTrainer(slot_tagger, slot_corpus)
|
||||
slot_trainer.train('slot-model',
|
||||
learning_rate=0.1,
|
||||
mini_batch_size=32,
|
||||
max_epochs=30,
|
||||
train_with_dev=False)
|
||||
|
||||
|
||||
frame_trainer = ModelTrainer(frame_tagger, frame_corpus)
|
||||
frame_trainer.train('frame-model',
|
||||
learning_rate=0.1,
|
||||
mini_batch_size=32,
|
||||
max_epochs=30,
|
||||
train_with_dev=False)
|
@ -1,7 +0,0 @@
|
||||
B-greeting
|
||||
B-doctor
|
||||
I-doctor
|
||||
B-datetime
|
||||
I-datetime
|
||||
B-id
|
||||
B-password
|
922
Janet.conllu
922
Janet.conllu
@ -1,922 +0,0 @@
|
||||
# text: Chciałem prosić o wypisanie kolejnej recepty na lek X
|
||||
# intent: prescription/request
|
||||
# slots:
|
||||
1 chciałem prescription/request NoLabel
|
||||
2 prosić prescription/request NoLabel
|
||||
3 o prescription/request NoLabel
|
||||
4 wypisanie prescription/request NoLabel
|
||||
5 kolejnej prescription/request NoLabel
|
||||
6 recepty prescription/request B-prescription/type
|
||||
7 na prescription/request NoLabel
|
||||
8 lek prescription/request B-prescription/medicine
|
||||
9 x prescription/request I-prescription/medicine
|
||||
|
||||
# text: proszę o E-receptę
|
||||
# intent: prescription/request
|
||||
# slots:
|
||||
1 proszę prescription/request NoLabel
|
||||
2 o prescription/request NoLabel
|
||||
3 ereceptę prescription/request B-prescription/type
|
||||
|
||||
# text: dziękuję
|
||||
# intent: end_conversation
|
||||
# slots:
|
||||
1 dziękuję end_conversation B-end_conversation
|
||||
|
||||
# text: Nie to wszystko Dziękuję za rozmowę
|
||||
# intent: end_conversation
|
||||
# slots:
|
||||
1 nie end_conversation B-deny
|
||||
2 to end_conversation B-end_conversation
|
||||
3 wszystko end_conversation I-end_conversation
|
||||
4 dziękuję end_conversation I-end_conversation
|
||||
5 za end_conversation I-end_conversation
|
||||
6 rozmowę end_conversation I-end_conversation
|
||||
|
||||
# text: Dzień dobry!
|
||||
# intent: greeting
|
||||
# slots:
|
||||
1 dzień greeting B-greeting
|
||||
2 dobry greeting I-greeting
|
||||
|
||||
# text: dzień dobry chciałbym umówić się na wizytę u lekarza internisty
|
||||
# intent: appointment/create_appointment
|
||||
# slots:
|
||||
1 dzień appointment/create_appointment B-greeting
|
||||
2 dobry appointment/create_appointment I-greeting
|
||||
3 chciałbym appointment/create_appointment NoLabel
|
||||
4 umówić appointment/create_appointment NoLabel
|
||||
5 się appointment/create_appointment NoLabel
|
||||
6 na appointment/create_appointment NoLabel
|
||||
7 wizytę appointment/create_appointment B-appointment
|
||||
8 u appointment/create_appointment NoLabel
|
||||
9 lekarza appointment/create_appointment B-doctor
|
||||
10 internisty appointment/create_appointment I-doctor
|
||||
|
||||
# text: Nie mam swojego identyfikatora nie pamiętam
|
||||
# intent: login/forgot_id
|
||||
# slots:
|
||||
1 nie login/forgot_id NoLabel
|
||||
2 mam login/forgot_id NoLabel
|
||||
3 swojego login/forgot_id NoLabel
|
||||
4 identyfikatora login/forgot_id NoLabel
|
||||
5 nie login/forgot_id NoLabel
|
||||
6 pamiętam login/forgot_id NoLabel
|
||||
|
||||
# text: mój identyfikator to: <identyfikator>
|
||||
# intent: login/enter_id
|
||||
# slots:
|
||||
1 mój login/enter_id NoLabel
|
||||
2 identyfikator login/enter_id NoLabel
|
||||
3 to login/enter_id NoLabel
|
||||
4 <identyfikator> login/enter_id NoLabel
|
||||
|
||||
# text: czy są dostępne jakieś wizyty w terminie 20.04.2021 u dr Adam Skrzypczak?
|
||||
# intent: request_information/available_dates
|
||||
# slots:
|
||||
1 czy request_information/available_dates NoLabel
|
||||
2 są request_information/available_dates NoLabel
|
||||
3 dostępne request_information/available_dates NoLabel
|
||||
4 jakieś request_information/available_dates NoLabel
|
||||
5 wizyty request_information/available_dates B-appointment
|
||||
6 w request_information/available_dates NoLabel
|
||||
7 terminie request_information/available_dates NoLabel
|
||||
8 20.04.2021 request_information/available_dates B-datetime
|
||||
9 u request_information/available_dates NoLabel
|
||||
10 dr request_information/available_dates B-doctor
|
||||
11 adam request_information/available_dates I-doctor
|
||||
12 skrzypczak request_information/available_dates I-doctor
|
||||
|
||||
# text: tak
|
||||
# intent: affirm
|
||||
# slots:
|
||||
1 tak affirm B-affirm
|
||||
|
||||
# text: jakie są dostępne terminy wizyt na 20.04.2021 u dowolnego internisty?
|
||||
# intent: request_information/available_dates
|
||||
# slots:
|
||||
1 jakie request_information/available_dates NoLabel
|
||||
2 są request_information/available_dates NoLabel
|
||||
3 dostępne request_information/available_dates NoLabel
|
||||
4 terminy request_information/available_dates NoLabel
|
||||
5 wizyt request_information/available_dates B-appointment
|
||||
6 na request_information/available_dates NoLabel
|
||||
7 20.04.2021 request_information/available_dates B-datetime
|
||||
8 u request_information/available_dates NoLabel
|
||||
9 dowolnego request_information/available_dates NoLabel
|
||||
10 internisty request_information/available_dates B-doctor
|
||||
|
||||
# text: prosze o rejestrację do mrożego na 12:00 dziękuję to wszystko
|
||||
# intent: appointment/create_appointment
|
||||
# slots:
|
||||
1 prosze appointment/create_appointment NoLabel
|
||||
2 o appointment/create_appointment NoLabel
|
||||
3 rejestrację appointment/create_appointment NoLabel
|
||||
4 do appointment/create_appointment NoLabel
|
||||
5 mrożego appointment/create_appointment B-doctor
|
||||
6 na appointment/create_appointment NoLabel
|
||||
7 12:00 appointment/create_appointment B-datetime
|
||||
8 dziękuję appointment/create_appointment B-end_conversation
|
||||
9 to appointment/create_appointment I-end_conversation
|
||||
10 wszystko appointment/create_appointment I-end_conversation
|
||||
|
||||
# text: Witam Chciałbym zarezerwować wizytę u lekarza
|
||||
# intent: appointment/create_appointment
|
||||
# slots:
|
||||
1 witam appointment/create_appointment B-greeting
|
||||
2 chciałbym appointment/create_appointment NoLabel
|
||||
3 zarezerwować appointment/create_appointment NoLabel
|
||||
4 wizytę appointment/create_appointment B-appointment
|
||||
5 u appointment/create_appointment NoLabel
|
||||
6 lekarza appointment/create_appointment B-doctor
|
||||
|
||||
# text: 15.04.2021 12:00
|
||||
# intent: appointment/set_date
|
||||
# slots:
|
||||
1 15.04.2021 appointment/set_date B-datetime
|
||||
2 12:00 appointment/set_date I-datetime
|
||||
|
||||
# text: Ok dziękuję
|
||||
# intent: affirm
|
||||
# slots:
|
||||
1 ok affirm B-affirm
|
||||
2 dziękuję affirm B-end_conversation
|
||||
|
||||
# text: Dzień dobry
|
||||
# intent: greeting
|
||||
# slots:
|
||||
1 dzień greeting B-greeting
|
||||
2 dobry greeting I-greeting
|
||||
|
||||
# text: Chciałbym umówić się na wizytę u specjalisty
|
||||
# intent: appointment/create_appointment
|
||||
# slots:
|
||||
1 chciałbym appointment/create_appointment NoLabel
|
||||
2 umówić appointment/create_appointment NoLabel
|
||||
3 się appointment/create_appointment NoLabel
|
||||
4 na appointment/create_appointment NoLabel
|
||||
5 wizytę appointment/create_appointment B-appointment
|
||||
6 u appointment/create_appointment NoLabel
|
||||
7 specjalisty appointment/create_appointment B-doctor
|
||||
|
||||
# text: Proszę podać listę specjalistów
|
||||
# intent: request_information/doctors
|
||||
# slots:
|
||||
1 proszę request_information/doctors NoLabel
|
||||
2 podać request_information/doctors NoLabel
|
||||
3 listę request_information/doctors NoLabel
|
||||
4 specjalistów request_information/doctors NoLabel
|
||||
|
||||
# text: Chciałbym wizytę u Internista Andrzej Mroży
|
||||
# intent: appointment/create_appointment
|
||||
# slots:
|
||||
1 chciałbym appointment/create_appointment NoLabel
|
||||
2 wizytę appointment/create_appointment NoLabel
|
||||
3 u appointment/create_appointment NoLabel
|
||||
4 internista appointment/create_appointment B-doctor
|
||||
5 andrzej appointment/create_appointment I-doctor
|
||||
6 mroży appointment/create_appointment I-doctor
|
||||
|
||||
# text: wybieram termin 15.04.2021 o 14:30
|
||||
# intent: appointment/set_date appointment/set_time
|
||||
# slots:
|
||||
1 wybieram appointment/set_date NoLabel
|
||||
2 termin appointment/set_date NoLabel
|
||||
3 15.04.2021 appointment/set_date B-datetime
|
||||
4 o appointment/set_time NoLabel
|
||||
5 14:30 appointment/set_time B-datetime
|
||||
|
||||
# text: dziękuję
|
||||
# intent: end_conversation
|
||||
# slots:
|
||||
1 dziękuję end_conversation B-end_conversation
|
||||
|
||||
# text: Dzień dobry
|
||||
# intent: greeting
|
||||
# slots:
|
||||
1 dzień greeting B-greeting
|
||||
2 dobry greeting I-greeting
|
||||
|
||||
# text: Chciałabym odwołać wizytę
|
||||
# intent: appointment/cancel
|
||||
# slots:
|
||||
1 chciałabym appointment/cancel NoLabel
|
||||
2 odwołać appointment/cancel NoLabel
|
||||
3 wizytę appointment/cancel B-appointment
|
||||
|
||||
# text: owszem
|
||||
# intent: affirm
|
||||
# slots:
|
||||
1 owszem affirm B-affirm
|
||||
|
||||
# text: ok dzięki gdzie mam wizytę u dentysty Anny
|
||||
# intent: appointment/where
|
||||
# slots:
|
||||
1 ok appointment/where B-affirm
|
||||
2 dzięki appointment/where NoLabel
|
||||
3 gdzie appointment/where NoLabel
|
||||
4 mam appointment/where NoLabel
|
||||
5 wizytę appointment/where B-appointment
|
||||
6 u appointment/where NoLabel
|
||||
7 dentysty appointment/where B-doctor
|
||||
8 anny appointment/where I-doctor
|
||||
|
||||
# text: a jaki adres
|
||||
# intent: request_information/location
|
||||
# slots:
|
||||
1 a request_information/location NoLabel
|
||||
2 jaki request_information/location NoLabel
|
||||
3 adres request_information/location NoLabel
|
||||
|
||||
# text: Dzień dobry!
|
||||
# intent: greeting
|
||||
# slots:
|
||||
1 dzień greeting B-greeting
|
||||
2 dobry greeting I-greeting
|
||||
|
||||
# text: Chciałbym zarezerować wizytę u lekarza
|
||||
# intent: appointment/create_appointment
|
||||
# slots:
|
||||
1 chciałbym appointment/create_appointment NoLabel
|
||||
2 zarezerować appointment/create_appointment NoLabel
|
||||
3 wizytę appointment/create_appointment B-appointment
|
||||
4 u appointment/create_appointment NoLabel
|
||||
5 lekarza appointment/create_appointment B-doctor
|
||||
|
||||
# text: Chciałbym umówić wyzytę z dermatologiem
|
||||
# intent: appointment/create_appointment
|
||||
# slots:
|
||||
1 chciałbym appointment/create_appointment NoLabel
|
||||
2 umówić appointment/create_appointment NoLabel
|
||||
3 wyzytę appointment/create_appointment B-appointment
|
||||
4 z appointment/create_appointment B-doctor
|
||||
5 dermatologiem appointment/create_appointment I-doctor
|
||||
|
||||
# text: Który ma wcześniejszy termin?
|
||||
# intent: appointment/compare_dates
|
||||
# slots:
|
||||
1 który appointment/compare_dates NoLabel
|
||||
2 ma appointment/compare_dates NoLabel
|
||||
3 wcześniejszy appointment/compare_dates NoLabel
|
||||
4 termin appointment/compare_dates NoLabel
|
||||
|
||||
# text: To chciałbym zapisać się do Jana Kowalskiego
|
||||
# intent: appointment/create_appointment
|
||||
# slots:
|
||||
1 to appointment/create_appointment NoLabel
|
||||
2 chciałbym appointment/create_appointment NoLabel
|
||||
3 zapisać appointment/create_appointment NoLabel
|
||||
4 się appointment/create_appointment NoLabel
|
||||
5 do appointment/create_appointment NoLabel
|
||||
6 jana appointment/create_appointment B-doctor
|
||||
7 kowalskiego appointment/create_appointment I-doctor
|
||||
|
||||
# text: 15.04 o 14:30
|
||||
# intent: appointment/set_date_and_time
|
||||
# slots:
|
||||
1 15.04 appointment/set_date_and_time B-datetime
|
||||
2 o appointment/set_date_and_time I-datetime
|
||||
3 14:30 appointment/set_date_and_time I-datetime
|
||||
|
||||
# text: Ile będzie kosztowała?
|
||||
# intent: request_information/cost
|
||||
# slots:
|
||||
1 ile request_information/cost NoLabel
|
||||
2 będzie request_information/cost NoLabel
|
||||
3 kosztowała request_information/cost NoLabel
|
||||
|
||||
# text: W jakim gabinecie została umówiona wizyta?
|
||||
# intent: appointment/location
|
||||
# slots:
|
||||
1 w appointment/location NoLabel
|
||||
2 jakim appointment/location NoLabel
|
||||
3 gabinecie appointment/location B-appointment/office
|
||||
4 została appointment/location NoLabel
|
||||
5 umówiona appointment/location NoLabel
|
||||
6 wizyta appointment/location B-appointment
|
||||
|
||||
# text: Dziękuję to by było wszystko
|
||||
# intent: end_conversation
|
||||
# slots:
|
||||
1 dziękuję end_conversation B-end_conversation
|
||||
2 to end_conversation I-end_conversation
|
||||
3 by end_conversation I-end_conversation
|
||||
4 było end_conversation I-end_conversation
|
||||
5 wszystko end_conversation I-end_conversation
|
||||
|
||||
# text: Dzień dobry!
|
||||
# intent: greeting
|
||||
# slots:
|
||||
1 dzień greeting B-greeting
|
||||
2 dobry greeting I-greeting
|
||||
|
||||
# text: Chciałbym zarezerwać wizytę
|
||||
# intent: appointment/create_appointment
|
||||
# slots:
|
||||
1 chciałbym appointment/create_appointment NoLabel
|
||||
2 zarezerwać appointment/create_appointment NoLabel
|
||||
3 wizytę appointment/create_appointment B-appointment
|
||||
|
||||
# text: Jan kowalski
|
||||
# intent: appointment/select_doctor
|
||||
# slots:
|
||||
1 jan appointment/select_doctor B-doctor
|
||||
2 kowalski appointment/select_doctor I-doctor
|
||||
|
||||
# text: proszę o termin 14.04.2021 - 14:30
|
||||
# intent: appointment/set_date_time
|
||||
# slots:
|
||||
1 proszę appointment/set_date_time NoLabel
|
||||
2 o appointment/set_date_time NoLabel
|
||||
3 termin appointment/set_date_time NoLabel
|
||||
4 14.04.2021 appointment/set_date_time B-datetime
|
||||
6 14:30 appointment/set_date_time I-datetime
|
||||
|
||||
# text: Dziękuję
|
||||
# intent: end_conversation
|
||||
# slots:
|
||||
1 dziękuję end_conversation B-end_conversation
|
||||
|
||||
# text: Dzień dobry
|
||||
# intent: greeting
|
||||
# slots:
|
||||
1 dzień greeting B-greeting
|
||||
2 dobry greeting I-greeting
|
||||
|
||||
# text: Chciałabym odebrać receptę
|
||||
# intent: prescription/collect
|
||||
# slots:
|
||||
1 chciałabym prescription/collect NoLabel
|
||||
2 odebrać prescription/collect NoLabel
|
||||
3 receptę prescription/collect B-prescription/type
|
||||
|
||||
# text: Chciałabym zamówić receptę
|
||||
# intent: prescription/request
|
||||
# slots:
|
||||
1 chciałabym prescription/request NoLabel
|
||||
2 zamówić prescription/request NoLabel
|
||||
3 receptę prescription/request B-prescription/type
|
||||
|
||||
# text: Tak
|
||||
# intent: affirm
|
||||
# slots:
|
||||
1 tak affirm B-affirm
|
||||
|
||||
# text: Dr Anna Kowalska
|
||||
# intent: appointment/select_doctor
|
||||
# slots:
|
||||
1 dr appointment/select_doctor B-doctor
|
||||
2 anna appointment/select_doctor I-doctor
|
||||
3 kowalska appointment/select_doctor I-doctor
|
||||
|
||||
# text: Proszę zapisać mnie na termin 14.04.2021 13:30
|
||||
# intent: appointment/create_appointment
|
||||
# slots:
|
||||
1 proszę appointment/create_appointment NoLabel
|
||||
2 zapisać appointment/create_appointment NoLabel
|
||||
3 mnie appointment/create_appointment NoLabel
|
||||
4 na appointment/create_appointment NoLabel
|
||||
5 termin appointment/create_appointment NoLabel
|
||||
6 14.04.2021 appointment/create_appointment B-datetime
|
||||
7 13:30 appointment/create_appointment I-B-datetime
|
||||
|
||||
# text: Dziękuje
|
||||
# intent: end_conversation
|
||||
# slots:
|
||||
1 dziękuje end_conversation B-end_conversation
|
||||
|
||||
# text: Dzień dobry!
|
||||
# intent: greeting
|
||||
# slots:
|
||||
1 dzień greeting B-greeting
|
||||
2 dobry greeting I-greeting
|
||||
|
||||
# text: Dzień dobry Chciałabym sprawdzić wyniki swoich ostatnich badań
|
||||
# intent: appointment/results
|
||||
# slots:
|
||||
1 dzień appointment/results B-greeting
|
||||
2 dobry appointment/results I-greeting
|
||||
3 chciałabym appointment/results NoLabel
|
||||
4 sprawdzić appointment/results NoLabel
|
||||
5 wyniki appointment/results B-results
|
||||
6 swoich appointment/results NoLabel
|
||||
7 ostatnich appointment/results NoLabel
|
||||
8 badań appointment/results NoLabel
|
||||
|
||||
# text: Widzę wyniki badania okulistycznego Czy w pliku powinny znajdować się też dot badań cytologicznych?
|
||||
# intent: affirm, appointment/results
|
||||
# slots:
|
||||
1 widzę affirm NoLabel
|
||||
2 wyniki affirm B-results
|
||||
3 badania affirm B-appointment/type
|
||||
4 okulistycznego affirm I-appointment/type
|
||||
5 czy appointment/results NoLabel
|
||||
6 w appointment/results NoLabel
|
||||
7 pliku appointment/results NoLabel
|
||||
8 powinny appointment/results NoLabel
|
||||
9 znajdować appointment/results NoLabel
|
||||
10 się appointment/results NoLabel
|
||||
11 też appointment/results NoLabel
|
||||
12 dot appointment/results NoLabel
|
||||
13 badań appointment/results B-appointment/type
|
||||
14 cytologicznych appointment/results I-appointment/type
|
||||
|
||||
# text: Teraz chyba widzę wszystko czego potrzebuję Czy możesz mi powiedzieć na kiedy mam umówione następne wizyty?
|
||||
# intent: affirm appointment/when
|
||||
# slots:
|
||||
1 teraz affirm NoLabel
|
||||
2 chyba affirm NoLabel
|
||||
3 widzę affirm NoLabel
|
||||
4 wszystko affirm NoLabel
|
||||
5 czego affirm NoLabel
|
||||
6 potrzebuję affirm NoLabel
|
||||
7 czy appointment/when NoLabel
|
||||
8 możesz appointment/when NoLabel
|
||||
9 mi appointment/when NoLabel
|
||||
10 powiedzieć appointment/when NoLabel
|
||||
11 na appointment/when NoLabel
|
||||
12 kiedy appointment/when NoLabel
|
||||
13 mam appointment/when NoLabel
|
||||
14 umówione appointment/when NoLabel
|
||||
15 następne appointment/when NoLabel
|
||||
16 wizyty appointment/when B-appointment
|
||||
|
||||
# text: A o której mam dentystę?
|
||||
# intent: appointment/when
|
||||
# slots:
|
||||
1 a appointment/when NoLabel
|
||||
2 o appointment/when NoLabel
|
||||
3 której appointment/when NoLabel
|
||||
4 mam appointment/when NoLabel
|
||||
5 dentystę appointment/when B-doctor
|
||||
|
||||
# text: Ok Wszystko wiem dzięki!
|
||||
# intent: end_conversation
|
||||
# slots:
|
||||
1 ok end_conversation B-end_conversation
|
||||
2 wszystko end_conversation I-end_conversation
|
||||
3 wiem end_conversation I-end_conversation
|
||||
4 dzięki end_conversation I-end_conversation
|
||||
|
||||
# text: Hej
|
||||
# intent: greeting
|
||||
# slots:
|
||||
1 hej greeting B-greeting
|
||||
|
||||
# text: Dzień dobry chciałbym umówić się na USG tarczycy
|
||||
# intent: appointment/create_appointment
|
||||
# slots:
|
||||
1 dzień appointment/create_appointment B-greeting
|
||||
2 dobry appointment/create_appointment I-greeting
|
||||
3 chciałbym appointment/create_appointment NoLabel
|
||||
4 umówić appointment/create_appointment NoLabel
|
||||
5 się appointment/create_appointment NoLabel
|
||||
6 na appointment/create_appointment NoLabel
|
||||
7 usg appointment/create_appointment B-appointment/type
|
||||
8 tarczycy appointment/create_appointment I-appointment/type
|
||||
|
||||
# text: Dzień dobry
|
||||
# intent: greeting
|
||||
# slots:
|
||||
1 dzień greeting B-greeting
|
||||
2 dobry greeting I-greeting
|
||||
|
||||
# text: Chcialbym odebrać wyniki badań gastroskopii
|
||||
# intent: result/collect
|
||||
# slots:
|
||||
1 chcialbym result/collect NoLabel
|
||||
2 odebrać result/collect NoLabel
|
||||
3 wyniki result/collect B-results
|
||||
4 badań result/collect B-appointment/type
|
||||
5 gastroskopii result/collect I-appointment/type
|
||||
|
||||
# text: Jakie mam zaplanowane wizyty?
|
||||
# intent: appointment/check_appointments
|
||||
# slots:
|
||||
1 jakie appointment/check_appointments NoLabel
|
||||
2 mam appointment/check_appointments NoLabel
|
||||
3 zaplanowane appointment/check_appointments NoLabel
|
||||
4 wizyty? appointment/check_appointments NoLabel
|
||||
|
||||
# text: Chciałbym przenieść tą wizyte na 21.04.2021
|
||||
# intent: appointment/set_date
|
||||
# slots:
|
||||
1 chciałbym appointment/set_date NoLabel
|
||||
2 przenieść appointment/set_date NoLabel
|
||||
3 tą appointment/set_date NoLabel
|
||||
4 wizyte appointment/set_date B-appointment
|
||||
5 na appointment/set_date NoLabel
|
||||
6 21.04.2021 appointment/set_date B-datetime
|
||||
|
||||
# text: 17:15
|
||||
# intent: appointment/set_time
|
||||
# slots:
|
||||
1 17:15 appointment/set_time B-datetime
|
||||
|
||||
# text: Dziękuję bardzo
|
||||
# intent: end_conversation
|
||||
# slots:
|
||||
1 dziękuję end_conversation B-end_conversation
|
||||
2 bardzo end_conversation I-end_conversation
|
||||
|
||||
# text: Cześć
|
||||
# intent: greeting
|
||||
# slots:
|
||||
1 cześć greeting B-greeting
|
||||
|
||||
# text: Dziękuję to wszystko
|
||||
# intent: end_conversation
|
||||
# slots:
|
||||
1 dziękuję end_conversation B-end_conversation
|
||||
2 to end_conversation I-end_conversation
|
||||
3 wszystko end_conversation I-end_conversation
|
||||
|
||||
# text: Chciałbym się zapisać na wizytę do okulisty Jakie są dostępne terminy?
|
||||
# intent: appointment/create_appointment
|
||||
# slots:
|
||||
1 chciałbym appointment/create_appointment NoLabel
|
||||
2 się appointment/create_appointment NoLabel
|
||||
3 zapisać appointment/create_appointment NoLabel
|
||||
4 na appointment/create_appointment NoLabel
|
||||
5 wizytę appointment/create_appointment B-appointment
|
||||
6 do appointment/create_appointment NoLabel
|
||||
7 okulisty appointment/create_appointment B-doctor
|
||||
8 jakie appointment/create_appointment NoLabel
|
||||
9 są appointment/create_appointment NoLabel
|
||||
10 dostępne appointment/create_appointment NoLabel
|
||||
11 terminy? appointment/create_appointment NoLabel
|
||||
|
||||
# text: Chciałbym się zapisać na 14-ego jakie są dostępne godziny?
|
||||
# intent: appointment/create_appointment
|
||||
# slots:
|
||||
1 chciałbym appointment/create_appointment NoLabel
|
||||
2 się appointment/create_appointment NoLabel
|
||||
3 zapisać appointment/create_appointment NoLabel
|
||||
4 na appointment/create_appointment NoLabel
|
||||
5 14-ego appointment/create_appointment B-datetime
|
||||
6 jakie appointment/create_appointment NoLabel
|
||||
7 są appointment/create_appointment NoLabel
|
||||
8 dostępne appointment/create_appointment NoLabel
|
||||
9 godziny? appointment/create_appointment NoLabel
|
||||
|
||||
# text: Chciałbym tą 14:15
|
||||
# intent: appointment/set_time
|
||||
# slots:
|
||||
1 chciałbym appointment/set_time NoLabel
|
||||
2 tą appointment/set_time NoLabel
|
||||
3 14:15 appointment/set_time B-datetime
|
||||
|
||||
# text: Nie posiadam identyfikatora
|
||||
# intent: deny
|
||||
# slots:
|
||||
1 nie deny B-deny
|
||||
2 posiadam deny NoLabel
|
||||
3 identyfikatora deny NoLabel
|
||||
|
||||
# text: TAK
|
||||
# intent: affirm
|
||||
# slots:
|
||||
1 tak affirm B-affirm
|
||||
|
||||
# text: Jan Kowalski
|
||||
# intent: register/enter_name
|
||||
# slots:
|
||||
1 jan register/enter_name B-register/name
|
||||
2 kowalski register/enter_name I-register/name
|
||||
|
||||
# text: jankowalski@gmailcom
|
||||
# intent: register/enter_email
|
||||
# slots:
|
||||
1 jankowalski@gmailcom register/enter_email B-register/email
|
||||
|
||||
# text: Dziękuję za pomoc i miłego dnia
|
||||
# intent: end_conversation
|
||||
# slots:
|
||||
1 dziękuję end_conversation B-end_conversation
|
||||
2 za end_conversation I-end_conversation
|
||||
3 pomoc end_conversation I-end_conversation
|
||||
4 i end_conversation NoLabel
|
||||
5 miłego end_conversation NoLabel
|
||||
6 dnia end_conversation NoLabel
|
||||
|
||||
# text: Cześć
|
||||
# intent: greeting
|
||||
# slots:
|
||||
1 cześć greeting B-greeting
|
||||
|
||||
# text: Chciałem zapisać się na spotkanie na jutrzejszy dzień na godziny poranne
|
||||
# intent: appointment/create_appointment
|
||||
# slots:
|
||||
1 chciałem appointment/create_appointment NoLabel
|
||||
2 zapisać appointment/create_appointment NoLabel
|
||||
3 się appointment/create_appointment NoLabel
|
||||
4 na appointment/create_appointment NoLabel
|
||||
5 spotkanie appointment/create_appointment B-appointment
|
||||
6 na appointment/create_appointment NoLabel
|
||||
7 jutrzejszy appointment/create_appointment B-datetime
|
||||
8 dzień appointment/create_appointment I-datetime
|
||||
9 na appointment/create_appointment I-datetime
|
||||
10 godziny appointment/create_appointment I-datetime
|
||||
11 poranne appointment/create_appointment I-datetime
|
||||
|
||||
# text: Pani doktor Kowalskiej
|
||||
# intent: appointment/select_doctor
|
||||
# slots:
|
||||
1 pani appointment/select_doctor NoLabel
|
||||
2 doktor appointment/select_doctor NoLabel
|
||||
3 kowalskiej appointment/select_doctor B-doctor
|
||||
|
||||
# text: na 11
|
||||
# intent: appointment/set_time
|
||||
# slots:
|
||||
1 na appointment/set_time NoLabel
|
||||
2 11 appointment/set_time B-datetime
|
||||
|
||||
# text: Dobrze dziękuję za rozmowę
|
||||
# intent: end_conversation
|
||||
# slots:
|
||||
1 dobrze end_conversation B-end_conversation
|
||||
2 dziękuję end_conversation I-end_conversation
|
||||
3 za end_conversation I-end_conversation
|
||||
4 rozmowę end_conversation I-end_conversation
|
||||
|
||||
# text: Hej
|
||||
# intent: greeting
|
||||
# slots:
|
||||
1 hej greeting B-greeting
|
||||
|
||||
# text: Dzień dobry chciałbym umówić się na wizytę do lekarza rodzinnego Najlepiej dzisiaj w godzinach popołudniowych
|
||||
# intent: appointment/create_appointment
|
||||
# slots:
|
||||
1 dzień appointment/create_appointment B-greeting
|
||||
2 dobry appointment/create_appointment B-greeting
|
||||
3 chciałbym appointment/create_appointment NoLabel
|
||||
4 umówić appointment/create_appointment NoLabel
|
||||
5 się appointment/create_appointment NoLabel
|
||||
6 na appointment/create_appointment NoLabel
|
||||
7 wizytę appointment/create_appointment B-appointment
|
||||
8 do appointment/create_appointment NoLabel
|
||||
9 lekarza appointment/create_appointment B-doctor
|
||||
10 rodzinnego appointment/create_appointment I-doctor
|
||||
11 najlepiej appointment/create_appointment NoLabel
|
||||
12 dzisiaj appointment/create_appointment B-datetime
|
||||
13 w appointment/create_appointment I-datetime
|
||||
14 godzinach appointment/create_appointment I-datetime
|
||||
15 popołudniowych appointment/create_appointment I-datetime
|
||||
|
||||
# text: A czy mogę zapisać się do Pani doktor Zofii Wątroby?
|
||||
# intent: appointment/create_appointment
|
||||
# slots:
|
||||
1 a appointment/create_appointment NoLabel
|
||||
2 czy appointment/create_appointment NoLabel
|
||||
3 mogę appointment/create_appointment NoLabel
|
||||
4 zapisać appointment/create_appointment NoLabel
|
||||
5 się appointment/create_appointment NoLabel
|
||||
6 do appointment/create_appointment NoLabel
|
||||
7 pani appointment/create_appointment B-doctor
|
||||
8 doktor appointment/create_appointment I-doctor
|
||||
9 zofii appointment/create_appointment I-doctor
|
||||
10 wątroby appointment/create_appointment I-doctor
|
||||
|
||||
# text: Ten termin mi odpowiada!
|
||||
# intent: appointment/confirm
|
||||
# slots:
|
||||
1 ten appointment/confirm B-affirm
|
||||
2 termin appointment/confirm I-affirm
|
||||
3 mi appointment/confirm I-affirm
|
||||
4 odpowiada appointment/confirm I-affirm
|
||||
|
||||
# text: Tak bardzo dziękuję
|
||||
# intent: affirm
|
||||
# slots:
|
||||
1 tak affirm B-affirm
|
||||
2 bardzo affirm I-end_conversation
|
||||
3 dziękuję affirm I-end_conversation
|
||||
|
||||
# text: Chciałbym też od razu zrobić badania morfologii krwi Kiedy mogę przyjść na pobranie krwi?
|
||||
# intent: appointment/create_appointment request_information/opening_hours
|
||||
# slots:
|
||||
1 chciałbym appointment/create_appointment NoLabel
|
||||
2 też appointment/create_appointment NoLabel
|
||||
3 od appointment/create_appointment NoLabel
|
||||
4 razu appointment/create_appointment NoLabel
|
||||
5 zrobić appointment/create_appointment NoLabel
|
||||
6 badania appointment/create_appointment B-appointment/type
|
||||
7 morfologii appointment/create_appointment I-appointment/type
|
||||
8 krwi appointment/create_appointment I-appointment/type
|
||||
9 kiedy request_information/opening_hours NoLabel
|
||||
10 mogę request_information/opening_hours NoLabel
|
||||
11 przyjść request_information/opening_hours NoLabel
|
||||
12 na request_information/opening_hours NoLabel
|
||||
13 pobranie request_information/opening_hours B-appointment/type
|
||||
14 krwi request_information/opening_hours I-appointment/type
|
||||
|
||||
# text: Dziękuję bardzo za informację W takim przypadku to wszystko
|
||||
# intent: end_conversation
|
||||
# slots:
|
||||
1 dziękuję end_conversation B-end_conversation
|
||||
2 bardzo end_conversation I-end_conversation
|
||||
3 za end_conversation I-end_conversation
|
||||
4 informację end_conversation I-end_conversation
|
||||
5 w end_conversation NoLabel
|
||||
6 takim end_conversation NoLabel
|
||||
7 przypadku end_conversation NoLabel
|
||||
8 to end_conversation NoLabel
|
||||
9 wszystko end_conversation NoLabel
|
||||
|
||||
# text: Dzień dobry
|
||||
# intent: greeting
|
||||
# slots:
|
||||
1 dzień greeting B-greeting
|
||||
2 dobry greeting I-greeting
|
||||
|
||||
# text: Chcialbym odebrac receptę
|
||||
# intent: prescription/collect
|
||||
# slots:
|
||||
1 chcialbym prescription/collect NoLabel
|
||||
2 odebrac prescription/collect NoLabel
|
||||
3 receptę prescription/collect B-prescription/type
|
||||
|
||||
# text: e-receptę
|
||||
# intent: prescription/type_info
|
||||
# slots:
|
||||
1 e-receptę prescription/type_info B-prescription/type
|
||||
|
||||
# text: Tak
|
||||
# intent: affirm
|
||||
# slots:
|
||||
1 tak affirm B-affirm
|
||||
|
||||
# text: Chciałbym również umówić spotkanie z lekarzem internistą
|
||||
# intent: appointment/create_appointment
|
||||
# slots:
|
||||
1 chciałbym appointment/create_appointment NoLabel
|
||||
2 również appointment/create_appointment NoLabel
|
||||
3 umówić appointment/create_appointment NoLabel
|
||||
4 spotkanie appointment/create_appointment B-appointment
|
||||
5 z appointment/create_appointment NoLabel
|
||||
6 lekarzem appointment/create_appointment B-doctor
|
||||
7 internistą appointment/create_appointment I-doctor
|
||||
|
||||
# text: Tak
|
||||
# intent: affirm
|
||||
# slots:
|
||||
1 tak affirm B-affirm
|
||||
|
||||
# text: 12.04.2021
|
||||
# intent: appointment/set_date
|
||||
# slots:
|
||||
1 12.04.2021 appointment/set_date B-datetime
|
||||
|
||||
# text: 13:00
|
||||
# intent: appointment/set_time
|
||||
# slots:
|
||||
1 13:00 appointment/set_time B-datetime
|
||||
|
||||
# text: Tak
|
||||
# intent: affirm
|
||||
# slots:
|
||||
1 tak affirm B-affirm
|
||||
|
||||
# text: Gdzie obędzie się wizyta?
|
||||
# intent: appointment/where
|
||||
# slots:
|
||||
1 gdzie appointment/where NoLabel
|
||||
2 obędzie appointment/where NoLabel
|
||||
3 się appointment/where NoLabel
|
||||
4 wizyta? appointment/where B-appointment
|
||||
|
||||
# text: Dziękuję za pomoc
|
||||
# intent: end_conversation
|
||||
# slots:
|
||||
1 dziękuję end_conversation B-end_conversation
|
||||
2 za end_conversation I-end_conversation
|
||||
3 pomoc end_conversation I-end_conversation
|
||||
|
||||
# text: Cześć
|
||||
# intent: greeting
|
||||
# slots:
|
||||
1 cześć greeting B-greeting
|
||||
|
||||
# text: Chciałbym się dowiedzieć czy mam umówione jakieś wizyty
|
||||
# intent: appointment/check_appointments
|
||||
# slots:
|
||||
1 chciałbym appointment/check_appointments NoLabel
|
||||
2 się appointment/check_appointments NoLabel
|
||||
3 dowiedzieć appointment/check_appointments NoLabel
|
||||
4 czy appointment/check_appointments NoLabel
|
||||
5 mam appointment/check_appointments NoLabel
|
||||
6 umówione appointment/check_appointments NoLabel
|
||||
7 jakieś appointment/check_appointments NoLabel
|
||||
8 wizyty appointment/check_appointments B-appointment
|
||||
|
||||
# text: Chciałbym odwołać wizytę u internisty
|
||||
# intent: appointment/cancel
|
||||
# slots:
|
||||
1 chciałbym appointment/cancel NoLabel
|
||||
2 odwołać appointment/cancel NoLabel
|
||||
3 wizytę appointment/cancel B-appointment
|
||||
4 u appointment/cancel NoLabel
|
||||
5 internisty appointment/cancel B-doctor
|
||||
|
||||
# text: Tak
|
||||
# intent: affirm
|
||||
# slots:
|
||||
1 tak affirm B-affirm
|
||||
|
||||
# text: Jacy lekarze specjaliści przyjmują w państwa przychodni?
|
||||
# intent: request_information/doctors
|
||||
# slots:
|
||||
1 jacy request_information/doctors NoLabel
|
||||
2 lekarze request_information/doctors B-doctor
|
||||
3 specjaliści request_information/doctors B-doctor
|
||||
4 przyjmują request_information/doctors NoLabel
|
||||
5 w request_information/doctors NoLabel
|
||||
6 państwa request_information/doctors NoLabel
|
||||
7 przychodni? request_information/doctors NoLabel
|
||||
|
||||
# text: Chciałbym umówić wizytę do doktora Kolano
|
||||
# intent: appointment/create_appointment
|
||||
# slots:
|
||||
1 chciałbym appointment/create_appointment NoLabel
|
||||
2 umówić appointment/create_appointment NoLabel
|
||||
3 wizytę appointment/create_appointment B-appointment
|
||||
4 do appointment/create_appointment NoLabel
|
||||
5 doktora appointment/create_appointment B-doctor
|
||||
6 kolano appointment/create_appointment I-doctor
|
||||
|
||||
# text: Ten termin mi odpowiada
|
||||
# intent: appointment/confirm
|
||||
# slots:
|
||||
1 ten appointment/confirm NoLabel
|
||||
2 termin appointment/confirm NoLabel
|
||||
3 mi appointment/confirm NoLabel
|
||||
4 odpowiada appointment/confirm NoLabel
|
||||
|
||||
# text: tak
|
||||
# intent: affirm
|
||||
# slots:
|
||||
1 tak affirm B-affirm
|
||||
|
||||
# text: Nie to wszystko Do widzenia
|
||||
# intent: end_conversation
|
||||
# slots:
|
||||
1 nie end_conversation B-deny
|
||||
2 to end_conversation B-end_conversation
|
||||
3 wszystko end_conversation I-end_conversation
|
||||
4 do end_conversation I-end_conversation
|
||||
5 widzenia end_conversation I-end_conversation
|
||||
|
||||
# text: Cześć
|
||||
# intent: greeting
|
||||
# slots:
|
||||
1 cześć greeting B-end_conversation
|
||||
|
||||
# text: Jakie usługi medyczne są dostępne?
|
||||
# intent: request_information/medical_services
|
||||
# slots:
|
||||
1 jakie request_information/medical_services NoLabel
|
||||
2 usługi request_information/medical_services NoLabel
|
||||
3 medyczne request_information/medical_services NoLabel
|
||||
4 są request_information/medical_services NoLabel
|
||||
5 dostępne request_information/medical_services NoLabel
|
||||
|
||||
# text: Chciałbym zapisać się do okulisty Ile kosztuje wizyta?
|
||||
# intent: appointment/create_appointment request_information/cost
|
||||
# slots:
|
||||
1 chciałbym appointment/create_appointment NoLabel
|
||||
2 zapisać appointment/create_appointment NoLabel
|
||||
3 się appointment/create_appointment NoLabel
|
||||
4 do appointment/create_appointment NoLabel
|
||||
5 okulisty appointment/create_appointment B-doctor
|
||||
6 ile request_information/cost NoLabel
|
||||
7 kosztuje request_information/cost NoLabel
|
||||
8 wizyta request_information/cost B-appointment
|
||||
|
||||
# text: Nie ten jest idealny
|
||||
# intent: deny
|
||||
# slots:
|
||||
1 nie affirm B-deny
|
||||
2 ten affirm NoLabel
|
||||
3 jest affirm NoLabel
|
||||
4 idealny affirm NoLabel
|
||||
|
||||
# text: Tak
|
||||
# intent: affirm
|
||||
# slots:
|
||||
1 tak affirm B-affirm
|
||||
|
||||
# text: Dziękuję za informację
|
||||
# intent: end_conversation
|
||||
# slots:
|
||||
1 dziękuję end_conversation B-end_conversation
|
||||
2 za end_conversation I-end_conversation
|
||||
3 informację end_conversation I-end_conversation
|
||||
|
||||
# text: Nie dziękuję to wszystko
|
||||
# intent: end_conversation
|
||||
# slots:
|
||||
1 nie end_conversation B-end_conversation
|
||||
2 dziękuję end_conversation I-end_conversation
|
||||
4 to end_conversation I-end_conversation
|
||||
5 wszystko end_conversation I-end_conversation
|
127
Makiety.py
Normal file
127
Makiety.py
Normal file
@ -0,0 +1,127 @@
|
||||
"""
|
||||
Przykład
|
||||
user: Cześć, jak masz na imię?
|
||||
system: Witaj, nazywam się Dia.
|
||||
"""
|
||||
|
||||
|
||||
class NLU: #Natural Language Understanding
|
||||
"""
|
||||
Moduł odpowiedzialny za analizę tekstu. W wyniku jego działania tekstowa reprezentacja wypowiedzi użytkownika zostaje zamieniona na jej reprezentację semantyczną, najczęściej w postaci ramy.
|
||||
|
||||
Wejście: Tekst
|
||||
|
||||
Wyjście: Akt użytkownika (rama)
|
||||
"""
|
||||
def __init__(self, acts, arguments):
|
||||
self.acts = acts
|
||||
self.arguments = arguments
|
||||
|
||||
def analyze(self, text):
|
||||
"""
|
||||
Analiza Tekstu wprowadzonego przez użytkownika i zamiana na akt (rama)
|
||||
"""
|
||||
print("Analiza Tekstu: " + text)
|
||||
act = "(greetings()&request(name))"
|
||||
print("Akt to: " + act)
|
||||
#przerobienie na wektor
|
||||
act_vector = [[0],[1,0]] #1 wektor to greetings, a 2 wektor to request z argumentem "name"
|
||||
print("Zamiana na: ")
|
||||
print(act_vector)
|
||||
return act_vector
|
||||
|
||||
class DST: #Dialogue State Tracker
|
||||
"""
|
||||
Moduł odpowiedzialny za śledzenie stanu dialogu. Przechowuje informacje o tym jakie dane zostały uzyskane od użytkownika w toku prowadzonej konwersacji.
|
||||
|
||||
Wejście: Akt użytkownika (rama)
|
||||
|
||||
Wyjście: Reprezentacja stanu dialogu (rama)
|
||||
"""
|
||||
def __init__(self, acts, arguments):
|
||||
self.acts = acts
|
||||
self.arguments = arguments
|
||||
self.frame_list= []
|
||||
|
||||
|
||||
def store(self, rama):
|
||||
"""
|
||||
Dodanie nowego aktu do listy
|
||||
"""
|
||||
print("\nDodanie do listy nowej ramy: ")
|
||||
print(rama)
|
||||
self.frame_list.append(rama)
|
||||
|
||||
|
||||
def transfer(self):
|
||||
print("Przekazanie dalej listy ram: ")
|
||||
print(self.frame_list)
|
||||
return self.frame_list
|
||||
|
||||
class DP:
|
||||
"""
|
||||
Moduł decydujący o wyborze kolejnego aktu, który ma podjąć system prowadząc rozmowę.
|
||||
|
||||
Wejście: Reprezentacja stanu dialogu (rama)
|
||||
|
||||
Wyjście: Akt systemu (rama)
|
||||
"""
|
||||
def __init__(self, acts, arguments):
|
||||
self.acts = acts
|
||||
self.arguments = arguments
|
||||
|
||||
|
||||
def choose_tactic(self, frame_list):
|
||||
"""
|
||||
Obieranie taktyki na podstawie aktów usera. Bardzo ważna jest kolejność dodawanych do frame_list wartości.
|
||||
"""
|
||||
act_vector = [0, 0]
|
||||
return act_vector
|
||||
|
||||
class NLG:
|
||||
"""
|
||||
Moduł, który tworzy reprezentację tekstową aktu systemowego wybranego przez taktykę dialogu.
|
||||
|
||||
Wejście: Akt systemu (rama)
|
||||
|
||||
Wyjście: Tekst
|
||||
"""
|
||||
def __init__(self, acts, arguments):
|
||||
self.acts = acts
|
||||
self.arguments = arguments
|
||||
|
||||
|
||||
def change_to_text(self, act_vector):
|
||||
"""
|
||||
Funkcja zamieniająca akt systemu na tekst rozumiany przez użytkownika.
|
||||
"""
|
||||
if(act_vector == [0, 0]):
|
||||
return "Cześć, mam na imię Janet"
|
||||
return "Nie rozumiem"
|
||||
|
||||
|
||||
class Janet:
|
||||
def __init__(self):
|
||||
self.acts={
|
||||
0: "greetings",
|
||||
1: "request",
|
||||
}
|
||||
self.arguments={
|
||||
0: "name"
|
||||
}
|
||||
self.nlg = NLG(self.acts, self.arguments)
|
||||
self.dp = DP(self.acts, self.arguments)
|
||||
self.dst = DST(self.acts, self.arguments)
|
||||
self.nlu = NLU(self.acts, self.arguments)
|
||||
|
||||
|
||||
def process(self, command):
|
||||
act = self.nlu.analyze(command)
|
||||
self.dst.store(act)
|
||||
dest_act = self.dp.choose_tactic(self.dst.transfer())
|
||||
return self.nlg.change_to_text(dest_act)
|
||||
|
||||
janet = Janet()
|
||||
while(1):
|
||||
text = input("Wpisz tekst: ")
|
||||
print(janet.process(text))
|
17
book.jsgf
17
book.jsgf
@ -1,17 +0,0 @@
|
||||
#JSGF V1.0 UTF-8 pl;
|
||||
|
||||
grammar book;
|
||||
|
||||
public <greeting> = hej | cześć | elo | dzień dobry | witam | siemanko | siemanko witam w mojej kuchni | gitara siema;
|
||||
|
||||
public <appointment> = chciałbym się umówić na wizytę <doctor> <dzien_rezerwacji>;
|
||||
|
||||
public <appointment_test> = chciałbym się umówić na wizytę <dzien_rezerwacji>;
|
||||
|
||||
<doctor> = do <imie_lekarza> {doctor_name};
|
||||
|
||||
<imie_lekarza> = Jana Kolano | Tomasza Łokieto | Piotra Pająka;
|
||||
|
||||
<dzien_rezerwacji> = na <dzien> {day};
|
||||
|
||||
<dzien> = dzisiaj | jutro | poniedziałek | wtorek | środę | czwartek | piątek | sobotę | niedzielę;
|
111
data.tsv
111
data.tsv
@ -1,111 +0,0 @@
|
||||
Text Intent
|
||||
Chciałem prosić o wypisanie kolejnej recepty na lek X appointment/request_prescription
|
||||
proszę o E-receptę appointment/request_prescription
|
||||
dziękuję end_conversation
|
||||
Nie to wszystko Dziękuję za rozmowę end_conversation
|
||||
Dzień dobry! greeting
|
||||
dzień dobry chciałbym umówić się na wizytę u lekarza internisty appointment/create_appointment
|
||||
Nie mam swojego identyfikatora nie pamiętam login/forgot_id
|
||||
mój identyfikator to: <identyfikator> login/enter_id
|
||||
czy są dostępne jakieś wizyty w terminie 20.04.2021 u dr Adam Skrzypczak? request_information/available_dates
|
||||
tak affirm
|
||||
jakie są dostępne terminy wizyt na 20.04.2021 u dowolnego internisty? request_information/available_dates
|
||||
prosze o rejestrację do mrożego na 12:00 dziękuję to wszystko appointment/create_appointment
|
||||
Witam Chciałbym zarezerwować wizytę u lekarza appointment/create_appointment
|
||||
15.04.2021 12:00 appointment/set_date
|
||||
Ok dziękuję affirm
|
||||
Dzień dobry greeting
|
||||
Chciałbym umówić się na wizytę u specjalisty appointment/create_appointment
|
||||
Proszę podać listę specjalistów request_information/doctors
|
||||
Chciałbym wizytę u Internista Andrzej Mroży appointment/create_appointment
|
||||
wybieram termin 15.04.2021 o 14:30 appointment/set_date appointment/set_time
|
||||
dziękuję end_conversation
|
||||
Dzień dobry greeting
|
||||
Chciałabym odwołać wizytę appointment/cancel
|
||||
owszem affirm
|
||||
ok dzięki gdzie mam wizytę u dentysty Anny appointment/where
|
||||
a jaki adres request_information/location
|
||||
Dzień dobry! greeting
|
||||
Chciałbym zarezerować wizytę u lekarza appointment/create_appointment
|
||||
Chciałbym umówić wyzytę z dermatologiem appointment/create_appointment
|
||||
Który ma wcześniejszy termin? appointment/compare_dates
|
||||
To chciałbym zapisać się do Jana Kowalskiego appointment/create_appointment
|
||||
15.04 o 14:30 appointment/set_date_and_time
|
||||
Ile będzie kosztowała? request_information/cost
|
||||
W jakim gabinecie została umówiona wizyta? appointment/location
|
||||
Dziękuję to by było wszystko end_conversation
|
||||
Dzień dobry! greeting
|
||||
Chciałbym zarezerwać wizytę appointment/create_appointment
|
||||
Jan kowalski appointment/select_doctor
|
||||
proszę o termin 14.04.2021 - 14:30 appointment/set_date_time
|
||||
Dziękuję end_conversation
|
||||
Dzień dobry greeting
|
||||
Chciałabym odebrać receptę prescription/collect
|
||||
Chciałabym zamówić receptę prescription/request
|
||||
Tak affirm
|
||||
Dr Anna Kowalska appointment/select_doctor
|
||||
Proszę zapisać mnie na termin 14.04.2021 13:30 appointment/create_appointment
|
||||
Dziękuje end_conversation
|
||||
Dzień dobry! greeting
|
||||
Dzień dobry Chciałabym sprawdzić wyniki swoich ostatnich badań appointment/results
|
||||
Widzę wyniki badania okulistycznego Czy w pliku powinny znajdować się też dot badań cytologicznych? affirm, appointment/results
|
||||
Teraz chyba widzę wszystko czego potrzebuję Czy możesz mi powiedzieć na kiedy mam umówione następne wizyty? affirm appointment/when
|
||||
A o której mam dentystę? appointment/when
|
||||
Ok Wszystko wiem dzięki! end_conversation
|
||||
Hej greeting
|
||||
Dzień dobry chciałbym umówić się na USG tarczycy appointment/create_appointment
|
||||
Dzień dobry greeting
|
||||
Chcialbym odebrać wyniki badań gastroskopii result/collect
|
||||
Jakie mam zaplanowane wizyty? appointment/check_appointments
|
||||
Chciałbym przenieść tą wizyte na 21.04.2021 appointment/set_date
|
||||
17:15 appointment/set_time
|
||||
Dziękuję bardzo end_conversation
|
||||
Cześć greeting
|
||||
Dziękuję to wszystko end_conversation
|
||||
Chciałbym się zapisać na wizytę do okulisty Jakie są dostępne terminy? appointment/create_appointment
|
||||
Chciałbym się zapisać na 14-ego jakie są dostępne godziny? appointment/create_appointment
|
||||
Chciałbym tą 14:15 appointment/set_time
|
||||
Nie posiadam identyfikatora deny
|
||||
TAK affirm
|
||||
Jan Kowalski register/enter_name
|
||||
jankowalski@gmailcom register/enter_email
|
||||
Dziękuję za pomoc i miłego dnia end_conversation
|
||||
Cześć greeting
|
||||
Chciałem zapisać się na spotkanie na jutrzejszy dzień na godziny poranne appointment/create_appointment
|
||||
Pani doktor Kowalskiej appointment/select_doctor
|
||||
na 11 appointment/set_time
|
||||
Dobrze dziękuję za rozmowę end_conversation
|
||||
Hej greeting
|
||||
Dzień dobry chciałbym umówić się na wizytę do lekarza rodzinnego Najlepiej dzisiaj w godzinach popołudniowych appointment/create_appointment
|
||||
A czy mogę zapisać się do Pani doktor Zofii Wątroby? appointment/create_appointment
|
||||
Ten termin mi odpowiada! appointment/confirm
|
||||
Tak bardzo dziękuję affirm
|
||||
Chciałbym też od razu zrobić badania morfologii krwi Kiedy mogę przyjść na pobranie krwi? appointment/create_appointment request_information/opening_hours
|
||||
Dziękuję bardzo za informację W takim przypadku to wszystko end_conversation
|
||||
Dzień dobry greeting
|
||||
Chcialbym odebrac receptę prescription/collect
|
||||
e-receptę prescription/type
|
||||
Tak affirm
|
||||
Chciałbym również umówić spotkanie z lekarzem internistą appointment/create_appointment
|
||||
Tak affirm
|
||||
12.04.2021 appointment/set_date
|
||||
13:00 appointment/set_time
|
||||
Tak affirm
|
||||
Gdzie obędzie się wizyta? appointment/where
|
||||
Dziękuję za pomoc end_conversation
|
||||
Cześć greeting
|
||||
Chciałbym się dowiedzieć czy mam umówione jakieś wizyty appointment/check_appointments
|
||||
Chciałbym odwołać wizytę u internisty appointment/cancel
|
||||
Tak affirm
|
||||
Jacy lekarze specjaliści przyjmują w państwa przychodni? request_information/doctors
|
||||
Chciałbym umówić wizytę do doktora Kolano appointment/create_appointment
|
||||
Ten termin mi odpowiada appointment/confirm
|
||||
tak affirm
|
||||
Nie to wszystko Do widzenia end_conversation
|
||||
Cześć greeting
|
||||
Jakie usługi medyczne są dostępne? request_information/medical_services
|
||||
Chciałbym zapisać się do okulisty Ile kosztuje wizyta? appointment/create_appointment request_information/cost
|
||||
Nie ten jest idealny deny
|
||||
Tak affirm
|
||||
Dziękuję za informację end_conversation
|
||||
Nie dziękuję to wszystko end_conversation
|
|
@ -1,29 +0,0 @@
|
||||
{
|
||||
"user_action": [],
|
||||
"system_action": [],
|
||||
"belief_state": {
|
||||
"appointment": {
|
||||
"name": "",
|
||||
"location": "",
|
||||
"doctor": "",
|
||||
"url": "",
|
||||
"type": "",
|
||||
"datetime": ""
|
||||
},
|
||||
"register": {
|
||||
"name": "",
|
||||
"secondname": "",
|
||||
"username": "",
|
||||
"password": ""
|
||||
},
|
||||
"request_information":{
|
||||
"doctor": "",
|
||||
"datetime": "",
|
||||
"appointment": "",
|
||||
"appointment/type": ""
|
||||
}
|
||||
},
|
||||
"request_state": {},
|
||||
"terminated": false,
|
||||
"history": []
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
# Evaluacja Systemu Dialogowego Janet
|
||||
|
||||
|
||||
- Średnia ocena systemu: 6,65/10
|
||||
- Zamiar rozmowy został rozpoznany w 88% przypadków
|
||||
- Cel został zrealizowany w 76% przypadków
|
||||
|
||||
## Czy system zrozumiał wszystko co mówiłeś?
|
||||
|
||||
- Tak - 2 odpowiedź
|
||||
- Prawie wszystko - 4 odpowiedzi
|
||||
- 50/50 - 8 odpowiedzi
|
||||
- Bardzo mało - 3 odpowiedzi
|
||||
- Nic - 0 odpowiedzi
|
||||
|
||||
|
||||
## Czy wiedziałeś co powiedzieć na każdym etapie dialogu?
|
||||
|
||||
- Tak - 4 odpowiedzi
|
||||
- Raczej tak - 7 odpowiedzi
|
||||
- Nie wiem - 3 odpowiedzi
|
||||
- Raczej nie - 3 odpowiedzi
|
||||
- Nie - 0 odpowiedzi
|
||||
|
||||
|
||||
## Czy odpowiedzi systemu były zrozumiałe?
|
||||
|
||||
- Tak - 2 odpowiedź
|
||||
- Raczej tak - 8 odpowiedzi
|
||||
- Nie wiem - 3 odpowiedzi
|
||||
- Raczej nie - 4 odpowiedzi
|
||||
- Nie - 0 odpowiedzi
|
||||
|
||||
## Czego brakowało w systemie?
|
||||
|
||||
- Większego zrozumienia dat i godzin
|
||||
- Obsługi większej ilości scenariuszy
|
||||
- Bardziej rozbudowanego wywiadu podczas umawiania wizyty
|
@ -1,21 +0,0 @@
|
||||
#JSGF V1.0 UTF-8 pl;
|
||||
|
||||
grammar book;
|
||||
|
||||
public <rezerwuj> = chciałbym zarezerwować stolik <dzien_rezerwacji> <godzina_rezerwacji> <liczba_osob> ;
|
||||
|
||||
<dzien_rezerwacji> = na <dzien> {day};
|
||||
|
||||
<dzien> = dzisiaj | jutro | poniedziałek | wtorek | środę | czwartek | piątek | sobotę | niedzielę;
|
||||
|
||||
<godzina_rezerwacji> = na [godzinę] <godzina_z_minutami> {hour};
|
||||
|
||||
<godzina_z_minutami> = <godzina> [<minuty>];
|
||||
|
||||
<godzina> = dziewiątą | dziesiątą | jedenastą | dwunastą;
|
||||
|
||||
<minuty> = pietnaście | trzydzieści;
|
||||
|
||||
<liczba_osob> = (na | dla) <liczba> {size} (osób | osoby);
|
||||
|
||||
<liczba> = dwie | dwóch | trzy | trzech | cztery | czterech | pięć | pieciu;
|
110
value_dict.json
110
value_dict.json
@ -1,110 +0,0 @@
|
||||
{
|
||||
"appointment": {
|
||||
"hour": [
|
||||
"08:00",
|
||||
"08:15",
|
||||
"08:30",
|
||||
"08:45",
|
||||
"09:00",
|
||||
"09:15",
|
||||
"09:30",
|
||||
"09:45",
|
||||
"10:00",
|
||||
"10:15",
|
||||
"10:30",
|
||||
"10:45",
|
||||
"11:00",
|
||||
"11:15",
|
||||
"11:30",
|
||||
"11:45",
|
||||
"12:00",
|
||||
"12:15",
|
||||
"12:30",
|
||||
"12:45",
|
||||
"13:00",
|
||||
"13:15",
|
||||
"13:30",
|
||||
"13:45",
|
||||
"14:00",
|
||||
"14:15",
|
||||
"14:30",
|
||||
"14:45",
|
||||
"15:00",
|
||||
"15:15",
|
||||
"15:30",
|
||||
"15:45",
|
||||
"16:00",
|
||||
"16:15",
|
||||
"16:30",
|
||||
"16:45",
|
||||
"17:00",
|
||||
"17:15",
|
||||
"17:30",
|
||||
"17:45",
|
||||
"18:00",
|
||||
"18:15",
|
||||
"18:30",
|
||||
"18:45",
|
||||
"19:00",
|
||||
"19:15",
|
||||
"19:30",
|
||||
"19:45"
|
||||
],
|
||||
"date": [
|
||||
"poniedziałek",
|
||||
"wtorek",
|
||||
"środa",
|
||||
"środę",
|
||||
"czwartek",
|
||||
"piątek",
|
||||
"sobota",
|
||||
"sobotę",
|
||||
"niedziela",
|
||||
"niedzielę",
|
||||
"01.05.2021",
|
||||
"02.05.2021",
|
||||
"03.05.2021",
|
||||
"04.05.2021",
|
||||
"05.05.2021",
|
||||
"06.05.2021",
|
||||
"07.05.2021",
|
||||
"08.05.2021",
|
||||
"09.05.2021",
|
||||
"10.05.2021",
|
||||
"11.05.2021",
|
||||
"12.05.2021",
|
||||
"13.05.2021",
|
||||
"14.05.2021",
|
||||
"15.05.2021",
|
||||
"16.05.2021",
|
||||
"17.05.2021",
|
||||
"18.05.2021",
|
||||
"19.05.2021",
|
||||
"20.05.2021",
|
||||
"21.05.2021",
|
||||
"22.05.2021",
|
||||
"23.05.2021",
|
||||
"24.05.2021",
|
||||
"25.05.2021",
|
||||
"26.05.2021",
|
||||
"27.05.2021",
|
||||
"28.05.2021",
|
||||
"29.05.2021",
|
||||
"20.05.2021"
|
||||
],
|
||||
"doctor": [
|
||||
"internista",
|
||||
"okulista",
|
||||
"rodzinny",
|
||||
"ginekolog",
|
||||
"dr. Kolano",
|
||||
"dr. Kowalska"
|
||||
]
|
||||
},
|
||||
"prescritpion": {
|
||||
"type": [
|
||||
"recepta",
|
||||
"e-recepta"
|
||||
]
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user