SystemyDialogowe/chatbot.ipynb

164 lines
6.6 KiB
Plaintext
Raw Normal View History

2022-06-07 23:26:14 +02:00
{
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"id": "encouraging-december",
"metadata": {},
"outputs": [
{
"name": "stdin",
"output_type": "stream",
"text": [
">>> chce 2 bilety\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"tytul\n",
"{'ilosc': '2', 'tytul': None, 'dzien': None, 'godzina': None}\n",
"Na jaki film ma zostać dokonana rezerwacja?\n"
]
},
{
"name": "stdin",
"output_type": "stream",
"text": [
">>> chce na film batman\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"ilosc\n",
"{'ilosc': None, 'tytul': 'Batman', 'dzien': None, 'godzina': None}\n",
"Ile biletów ma zostać zarezerwowanych?\n"
]
},
{
"name": "stdin",
"output_type": "stream",
"text": [
">>> chce 2 bilety\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"tytul\n",
"{'ilosc': '2', 'tytul': None, 'dzien': None, 'godzina': None}\n",
"Na jaki film ma zostać dokonana rezerwacja?\n"
]
},
{
"name": "stdin",
"output_type": "stream",
"text": [
">>> chce 2 bilety na film batman\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"dzien\n",
"{'ilosc': '2', 'tytul': 'Batman', 'dzien': None, 'godzina': None}\n",
"Na który dzień ma być dokonana rezerwacja?\n"
]
},
{
"name": "stdin",
"output_type": "stream",
"text": [
">>> chce na jutro\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"ilosc\n",
"{'ilosc': None, 'tytul': None, 'dzien': 'jutro', 'godzina': None}\n",
"Ile biletów ma zostać zarezerwowanych?\n"
]
},
{
"ename": "KeyboardInterrupt",
"evalue": "Interrupted by user",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-2-0b584a7b5a30>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 12\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 13\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 14\u001b[0;31m \u001b[0mtext\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0minput\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'>>>'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 15\u001b[0m \u001b[0mframe\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0majn\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtext\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 16\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/usr/local/lib/python3.7/dist-packages/ipykernel/kernelbase.py\u001b[0m in \u001b[0;36mraw_input\u001b[0;34m(self, prompt)\u001b[0m\n\u001b[1;32m 849\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_parent_ident\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 850\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_parent_header\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 851\u001b[0;31m \u001b[0mpassword\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mFalse\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 852\u001b[0m )\n\u001b[1;32m 853\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/usr/local/lib/python3.7/dist-packages/ipykernel/kernelbase.py\u001b[0m in \u001b[0;36m_input_request\u001b[0;34m(self, prompt, ident, parent, password)\u001b[0m\n\u001b[1;32m 890\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mKeyboardInterrupt\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 891\u001b[0m \u001b[0;31m# re-raise KeyboardInterrupt, to truncate traceback\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 892\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mKeyboardInterrupt\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"Interrupted by user\"\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 893\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mException\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0me\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 894\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mlog\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mwarning\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"Invalid Message:\"\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mexc_info\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mTrue\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mKeyboardInterrupt\u001b[0m: Interrupted by user"
]
}
],
"source": [
"from DST import Dst\n",
"from AJN import *\n",
"from NLG import nlg\n",
"\n",
"\n",
"\n",
"if __name__ == \"__main__\":\n",
" \n",
" dst = Dst()\n",
" next_question = dst.get_next_question()\n",
" while (next_question):\n",
" \n",
" \n",
" text = input('>>>')\n",
" frame = ajn(text)\n",
" \n",
" dst.save_answer(frame['slots'])\n",
" \n",
" next_question = dst.get_next_question()\n",
" print(next_question)\n",
" print(dst.checklist)\n",
"# print(frame['act'])\n",
" nlg(next_question)\n",
"\n",
" \n",
" \n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "yellow-acquisition",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 5
}