2023-06-01 12:30:30 +02:00
|
|
|
{
|
|
|
|
"cells": [
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": null,
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": [
|
|
|
|
"import random\n",
|
|
|
|
"\n",
|
|
|
|
"\n",
|
|
|
|
"def nlg(system_act):\n",
|
|
|
|
" domain, intent, slot, value = system_act\n",
|
|
|
|
"\n",
|
|
|
|
" if intent == 'Affirm':\n",
|
|
|
|
" r = random.randint(1, 3)\n",
|
|
|
|
"\n",
|
|
|
|
" if r == 1:\n",
|
|
|
|
" return 'Tak'\n",
|
|
|
|
" elif r == 2:\n",
|
|
|
|
" return 'Zgadza się'\n",
|
|
|
|
" else:\n",
|
|
|
|
" return 'Potwierdzam'\n",
|
2023-06-01 13:27:55 +02:00
|
|
|
" \n",
|
|
|
|
" if intent == 'Deny':\n",
|
|
|
|
" r = random.randint(1, 3)\n",
|
|
|
|
"\n",
|
|
|
|
" if r == 1:\n",
|
|
|
|
" return 'Nie'\n",
|
|
|
|
" elif r == 2:\n",
|
|
|
|
" return 'Nie zgadza się'\n",
|
|
|
|
" else:\n",
|
|
|
|
" return 'Nie potwierdzam'\n",
|
2023-06-01 12:30:30 +02:00
|
|
|
" \n",
|
|
|
|
" if intent == 'Canthelp':\n",
|
|
|
|
" r = random.randint(1, 3)\n",
|
|
|
|
"\n",
|
|
|
|
" if r == 1:\n",
|
|
|
|
" return 'Przepraszam, ale obawiam się, że nie mogę tego zrobić'\n",
|
|
|
|
" elif r == 2:\n",
|
|
|
|
" return 'Wystąpił błąd, proszę się skontaktować z obsługą'\n",
|
|
|
|
" else:\n",
|
|
|
|
" return 'ERR://23¤Y%/'\n",
|
|
|
|
" \n",
|
2023-06-01 13:27:55 +02:00
|
|
|
" if intent == 'Hellomsg':\n",
|
|
|
|
" r = random.randint(1, 3)\n",
|
|
|
|
"\n",
|
|
|
|
" if r == 1:\n",
|
|
|
|
" return 'Witaj'\n",
|
|
|
|
" elif r == 2:\n",
|
|
|
|
" return 'Cześć'\n",
|
|
|
|
" else:\n",
|
|
|
|
" return 'Dzień dobry'\n",
|
|
|
|
" \n",
|
|
|
|
" if intent == 'Bye':\n",
|
|
|
|
" r = random.randint(1, 3)\n",
|
|
|
|
"\n",
|
|
|
|
" if r == 1:\n",
|
|
|
|
" return 'Do zobaczenia'\n",
|
|
|
|
" elif r == 2:\n",
|
|
|
|
" return 'Żegnaj'\n",
|
|
|
|
" else:\n",
|
|
|
|
" return 'Buk zapłać'\n",
|
|
|
|
" \n",
|
|
|
|
" \n",
|
|
|
|
"\n",
|
|
|
|
" if domain == 'Product':\n",
|
|
|
|
" if intent == 'Inform':\n",
|
|
|
|
" if slot == 'Quantity':\n",
|
|
|
|
" if value == 0:\n",
|
|
|
|
" return f'Nie znalazłem produktów spełniających podane kryteria.'\n",
|
|
|
|
" elif value == 1:\n",
|
|
|
|
" return f'Znalazłem jeden produkt spełniającą podane kryteria.'\n",
|
|
|
|
" elif value <= 4:\n",
|
|
|
|
" return f'Znalazłem {value} produkty spełniające podane kryteria.'\n",
|
|
|
|
" elif value <= 9:\n",
|
|
|
|
" return f'Znalazłem {value} produktów spełniających podane kryteria.'\n",
|
|
|
|
" else:\n",
|
|
|
|
" return f'Znalazłem wiele produktów spełniających podane kryteria.'\n",
|
|
|
|
" elif slot == 'Quality':\n",
|
|
|
|
" return f'Znalazłem produkt(y) jakości {value}'\n",
|
|
|
|
" elif slot == 'Price_range':\n",
|
|
|
|
" return f'Znalazłem produkt(y) w przedziale cenowym {value}'\n",
|
|
|
|
" elif slot == 'Type':\n",
|
|
|
|
" return f'Znalazłem produkt(y) typu {value}'\n",
|
|
|
|
" elif slot == 'Brand':\n",
|
|
|
|
" return f'Znalazłem produkt(y) marki {value}'\n",
|
|
|
|
" elif slot == 'Price':\n",
|
|
|
|
" return f'Znalazlem produkt(y) w cenie {value}'\n",
|
|
|
|
" if intent == 'Request':\n",
|
|
|
|
" if slot == 'CreditCardNo':\n",
|
|
|
|
" return 'Podaj nuber karty płatniczej'\n",
|
|
|
|
" if slot == 'Quantity':\n",
|
|
|
|
" return 'Podaj liczbę artykułów'\n",
|
|
|
|
" #if slot == 'Quality':\n",
|
|
|
|
" # return 'Podaj jakość produktów'\n",
|
|
|
|
" if slot == 'Type':\n",
|
|
|
|
" return 'Podaj typ produktu'\n",
|
|
|
|
" if intent == 'Recommend':\n",
|
|
|
|
" if slot == \"Name\":\n",
|
|
|
|
" r = random.randint(1, 3)\n",
|
|
|
|
"\n",
|
|
|
|
" if r == 1:\n",
|
|
|
|
" return f'Kochany użytkowniku, z całego serduszka polecam Ci {value}'\n",
|
|
|
|
" elif r == 2:\n",
|
|
|
|
" return f'Polecam {value}'\n",
|
|
|
|
" else:\n",
|
|
|
|
" return f'Mogę polecić {value}'\n",
|
2023-06-01 12:30:30 +02:00
|
|
|
"\n",
|
2023-06-01 13:27:55 +02:00
|
|
|
" "
|
2023-06-01 12:30:30 +02:00
|
|
|
]
|
2023-06-01 13:27:55 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"cell_type": "code",
|
|
|
|
"execution_count": null,
|
|
|
|
"metadata": {},
|
|
|
|
"outputs": [],
|
|
|
|
"source": []
|
2023-06-01 12:30:30 +02:00
|
|
|
}
|
|
|
|
],
|
|
|
|
"metadata": {
|
|
|
|
"language_info": {
|
|
|
|
"name": "python"
|
|
|
|
},
|
|
|
|
"orig_nbformat": 4
|
|
|
|
},
|
|
|
|
"nbformat": 4,
|
|
|
|
"nbformat_minor": 2
|
|
|
|
}
|