219 lines
6.5 KiB
Plaintext
219 lines
6.5 KiB
Plaintext
![]() |
{
|
||
|
"cells": [
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 17,
|
||
|
"id": "9a772dd1",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"import random"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 21,
|
||
|
"id": "54502dca",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"def nlg(system_act):\n",
|
||
|
" intent, domain, slot, value = system_act\n",
|
||
|
"\n",
|
||
|
" if domain == 'payment' and intent == 'inform':\n",
|
||
|
" if slot == 'type':\n",
|
||
|
" if value == 'blik' or value == 'gotówka' or value == 'karta kredytowa' or value == 'karta restauracyjna' or value == 'bon upominkowy':\n",
|
||
|
" return f\"Informuję, że {value} jest możliwą formą płatności w naszej restauracji.\"\n",
|
||
|
" else:\n",
|
||
|
" return f\"Informuję, że {value} nie jest możliwą formą płatności w naszej restauracji.\"\n",
|
||
|
" if slot == 'vat':\n",
|
||
|
" return f\"Twój vat jest {value} w rachunek.\"\n",
|
||
|
" if slot == 'amount':\n",
|
||
|
" return f\"Kwota Twojej płatności to {value}.\"\n",
|
||
|
" else:\n",
|
||
|
" return \"Nie mogę wykonać takiej operacji.\"\n",
|
||
|
" elif domain == 'booking' and intent == 'inform':\n",
|
||
|
" if slot == 'area':\n",
|
||
|
" return f\"Ta restauracja znajduje się w dzielnicy {value}.\"\n",
|
||
|
" if slot == 'restaurant_name':\n",
|
||
|
" return f\"Oto twoja rezerwacja w {value}.\"\n",
|
||
|
" if slot == \"book people\":\n",
|
||
|
" if value == 0:\n",
|
||
|
" return f'Nie można zarezerwować stolika dla 0 osób.'\n",
|
||
|
" elif value == 1:\n",
|
||
|
" return f'Można zarezerwować stolik dla Ciebie.'\n",
|
||
|
" elif value <= 10:\n",
|
||
|
" return f'Znalazłem stolik dla {value} osób.'\n",
|
||
|
" elif value >= 11:\n",
|
||
|
" return f'Nie ma stoliku dla {value} osób.'\n",
|
||
|
" else:\n",
|
||
|
" return f'Nie znalazłem stolików dla podanych kryterów.'\n",
|
||
|
" if slot == \"book day\":\n",
|
||
|
" return f\"Dzień Twojej rezerwacji to: {value}.\"\n",
|
||
|
" if slot == \"book time\":\n",
|
||
|
" return f\"Godzina Twojej rezerwacji to: {value}.\"\n",
|
||
|
" elif domain == \"order\" and intent == \"inform\":\n",
|
||
|
" if slot == \"type\":\n",
|
||
|
" if value == \"na wynos\":\n",
|
||
|
" return f'Twoje zamówienie zostanie może zostać przygotowane do odbioru na wynos.'\n",
|
||
|
" elif value == \"na miejscu\":\n",
|
||
|
" return f'Możesz odebrać zamówienie na miejscu.'\n",
|
||
|
" elif value == \"dostawa\":\n",
|
||
|
" return f'Twoje zamówienie może być zrealizowane w formie dostawy.'\n",
|
||
|
" if slot == \"price range\":\n",
|
||
|
" return f\"Porównując do cen w innych restauracjach, kwota Twojego zamówienia jest: {value}.\"\n",
|
||
|
" if slot == \"restaurant_name\":\n",
|
||
|
" return f\"Zamówienie zostanie wykonane przez {value}.\"\n",
|
||
|
" if slot == \"area\":\n",
|
||
|
" return f\"Zamówienie zostanie zrealizowane w dzielnicy {value}.\"\n",
|
||
|
" if slot == \"book time\":\n",
|
||
|
" return f\"Godzina Twojego zamówienia to: {value}.\"\n",
|
||
|
" if slot == \"book day\":\n",
|
||
|
" return f\"Dzień Twojego zamówienia to: {value}.\"\n",
|
||
|
" \n",
|
||
|
"\n",
|
||
|
" elif intent == 'end_conversation':\n",
|
||
|
" return random.choice(['Żegnam i dziękuję za skorzystanie z usługi.', 'Do widzenia.', \"Dziękuję za skorzystanie z usługi, do kolejnego razu.\"])\n",
|
||
|
" elif intent == 'start_conversation':\n",
|
||
|
" return random.choice(['Witaj, jestem asystentem dialogowym, dzięki któremu złożysz zamówienie w restuaracji.', 'Cześć, w czym mogę pomóc?', \"Witam w usłudze, w czym mogę pomóc?\"])\n",
|
||
|
" \n",
|
||
|
" "
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 11,
|
||
|
"id": "8568ac20",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"'Informuję, że gotówka jest możliwą formą płatności w naszej restauracji.'"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 11,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"nlg(['inform', 'payment', 'type', 'gotówka'])"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 12,
|
||
|
"id": "c3fa168f",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"'Twoje zamówienie zostanie może zostać przygotowane do odbioru na wynos.'"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 12,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"nlg(['inform', 'order', 'type', 'na wynos'])"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 13,
|
||
|
"id": "5ac835de",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"'Oto twoja rezerwacja w biały kwiat.'"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 13,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"nlg(['inform', 'booking', 'restaurant_name', 'biały kwiat'])"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 19,
|
||
|
"id": "6c06463d",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"'Żegnam.'"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 19,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"nlg(['end_conversation', '', '', ''])"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 25,
|
||
|
"id": "aeaa9968",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"'Cześć, w czym mogę pomóc?'"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 25,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"nlg(['start_conversation', '', '', ''])"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"id": "e48c1960",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": []
|
||
|
}
|
||
|
],
|
||
|
"metadata": {
|
||
|
"kernelspec": {
|
||
|
"display_name": "Python 3 (ipykernel)",
|
||
|
"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.11.2"
|
||
|
}
|
||
|
},
|
||
|
"nbformat": 4,
|
||
|
"nbformat_minor": 5
|
||
|
}
|