architecture_v2

This commit is contained in:
Mikołaj Mrożewski 2023-04-14 13:11:32 +02:00
parent e1d9e9944e
commit 8b0b630186

View File

@ -14,7 +14,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 9, "execution_count": 13,
"id": "8a7292e7-a5b5-41c3-bd3f-11b619ed3f12", "id": "8a7292e7-a5b5-41c3-bd3f-11b619ed3f12",
"metadata": { "metadata": {
"tags": [] "tags": []
@ -25,8 +25,11 @@
"\n", "\n",
"def system(text):\n", "def system(text):\n",
" akt_usera = nlu(text)\n", " akt_usera = nlu(text)\n",
" print(akt_usera)\n",
" stan = dst(akt_usera)\n", " stan = dst(akt_usera)\n",
" print(stan)\n",
" akt_systemu = dialogue_policy(stan)\n", " akt_systemu = dialogue_policy(stan)\n",
" print(akt_systemu)\n",
" system_msg = nlg(akt_systemu)\n", " system_msg = nlg(akt_systemu)\n",
" print('System: ' + system_msg)\n", " print('System: ' + system_msg)\n",
" \n", " \n",
@ -41,26 +44,27 @@
" return akt\n", " return akt\n",
"\n", "\n",
"def dst(akt):\n", "def dst(akt):\n",
" if akt == 'request(name)':\n", " if akt == 'request(imie)':\n",
" need = 'name'\n", " state = 'need imie'\n",
" return need\n", " return state\n",
" \n", " \n",
" \n", " \n",
"def dialogue_policy(state):\n", "def dialogue_policy(state):\n",
" state = state.split('(')\n", " state = state.split()\n",
" if state[0] == 'request':\n", " print('state: ', state)\n",
" if state[0] == 'need':\n",
" system_act = 'inform' + '(' + state[1] + ')'\n", " system_act = 'inform' + '(' + state[1] + ')'\n",
" return system_act\n", " return system_act\n",
" \n", " \n",
"def nlg(act):\n", "def nlg(act):\n",
" if act == 'request(imie)':\n", " if act == 'inform(imie)':\n",
" print('nazywam się ' + name)\n", " return name\n",
" \n" " \n"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 10, "execution_count": null,
"id": "52dc2673-0590-4b9f-87bc-f19a41e00746", "id": "52dc2673-0590-4b9f-87bc-f19a41e00746",
"metadata": { "metadata": {
"tags": [] "tags": []
@ -74,16 +78,14 @@
] ]
}, },
{ {
"ename": "AttributeError", "name": "stdout",
"evalue": "'NoneType' object has no attribute 'split'", "output_type": "stream",
"output_type": "error", "text": [
"traceback": [ "request(imie)\n",
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", "need imie\n",
"\u001b[1;31mAttributeError\u001b[0m Traceback (most recent call last)", "state: ['need', 'imie']\n",
"Cell \u001b[1;32mIn[10], line 3\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[38;5;28;01mwhile\u001b[39;00m \u001b[38;5;28;01mTrue\u001b[39;00m:\n\u001b[0;32m 2\u001b[0m user_input \u001b[38;5;241m=\u001b[39m \u001b[38;5;28minput\u001b[39m(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mTy:\u001b[39m\u001b[38;5;124m'\u001b[39m)\n\u001b[1;32m----> 3\u001b[0m \u001b[43msystem\u001b[49m\u001b[43m(\u001b[49m\u001b[43muser_input\u001b[49m\u001b[43m)\u001b[49m\n", "inform(imie)\n",
"Cell \u001b[1;32mIn[9], line 6\u001b[0m, in \u001b[0;36msystem\u001b[1;34m(text)\u001b[0m\n\u001b[0;32m 4\u001b[0m akt_usera \u001b[38;5;241m=\u001b[39m nlu(text)\n\u001b[0;32m 5\u001b[0m stan \u001b[38;5;241m=\u001b[39m dst(akt_usera)\n\u001b[1;32m----> 6\u001b[0m akt_systemu \u001b[38;5;241m=\u001b[39m \u001b[43mdialogue_policy\u001b[49m\u001b[43m(\u001b[49m\u001b[43mstan\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 7\u001b[0m system_msg \u001b[38;5;241m=\u001b[39m nlg(akt_systemu)\n\u001b[0;32m 8\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mSystem: \u001b[39m\u001b[38;5;124m'\u001b[39m \u001b[38;5;241m+\u001b[39m system_msg)\n", "System: Marek Suski\n"
"Cell \u001b[1;32mIn[9], line 27\u001b[0m, in \u001b[0;36mdialogue_policy\u001b[1;34m(state)\u001b[0m\n\u001b[0;32m 26\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mdialogue_policy\u001b[39m(state):\n\u001b[1;32m---> 27\u001b[0m state \u001b[38;5;241m=\u001b[39m \u001b[43mstate\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43msplit\u001b[49m(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m(\u001b[39m\u001b[38;5;124m'\u001b[39m)\n\u001b[0;32m 28\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m state[\u001b[38;5;241m0\u001b[39m] \u001b[38;5;241m==\u001b[39m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mrequest\u001b[39m\u001b[38;5;124m'\u001b[39m:\n\u001b[0;32m 29\u001b[0m system_act \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124minform\u001b[39m\u001b[38;5;124m'\u001b[39m \u001b[38;5;241m+\u001b[39m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124m(\u001b[39m\u001b[38;5;124m'\u001b[39m \u001b[38;5;241m+\u001b[39m state[\u001b[38;5;241m1\u001b[39m] \u001b[38;5;241m+\u001b[39m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124m)\u001b[39m\u001b[38;5;124m'\u001b[39m\n",
"\u001b[1;31mAttributeError\u001b[0m: 'NoneType' object has no attribute 'split'"
] ]
} }
], ],