architecture_v2
This commit is contained in:
parent
e1d9e9944e
commit
8b0b630186
@ -14,7 +14,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 9,
|
||||
"execution_count": 13,
|
||||
"id": "8a7292e7-a5b5-41c3-bd3f-11b619ed3f12",
|
||||
"metadata": {
|
||||
"tags": []
|
||||
@ -25,8 +25,11 @@
|
||||
"\n",
|
||||
"def system(text):\n",
|
||||
" akt_usera = nlu(text)\n",
|
||||
" print(akt_usera)\n",
|
||||
" stan = dst(akt_usera)\n",
|
||||
" print(stan)\n",
|
||||
" akt_systemu = dialogue_policy(stan)\n",
|
||||
" print(akt_systemu)\n",
|
||||
" system_msg = nlg(akt_systemu)\n",
|
||||
" print('System: ' + system_msg)\n",
|
||||
" \n",
|
||||
@ -41,26 +44,27 @@
|
||||
" return akt\n",
|
||||
"\n",
|
||||
"def dst(akt):\n",
|
||||
" if akt == 'request(name)':\n",
|
||||
" need = 'name'\n",
|
||||
" return need\n",
|
||||
" if akt == 'request(imie)':\n",
|
||||
" state = 'need imie'\n",
|
||||
" return state\n",
|
||||
" \n",
|
||||
" \n",
|
||||
"def dialogue_policy(state):\n",
|
||||
" state = state.split('(')\n",
|
||||
" if state[0] == 'request':\n",
|
||||
" state = state.split()\n",
|
||||
" print('state: ', state)\n",
|
||||
" if state[0] == 'need':\n",
|
||||
" system_act = 'inform' + '(' + state[1] + ')'\n",
|
||||
" return system_act\n",
|
||||
" \n",
|
||||
"def nlg(act):\n",
|
||||
" if act == 'request(imie)':\n",
|
||||
" print('nazywam się ' + name)\n",
|
||||
" if act == 'inform(imie)':\n",
|
||||
" return name\n",
|
||||
" \n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 10,
|
||||
"execution_count": null,
|
||||
"id": "52dc2673-0590-4b9f-87bc-f19a41e00746",
|
||||
"metadata": {
|
||||
"tags": []
|
||||
@ -74,16 +78,14 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"ename": "AttributeError",
|
||||
"evalue": "'NoneType' object has no attribute 'split'",
|
||||
"output_type": "error",
|
||||
"traceback": [
|
||||
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
|
||||
"\u001b[1;31mAttributeError\u001b[0m Traceback (most recent call last)",
|
||||
"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",
|
||||
"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",
|
||||
"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'"
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"request(imie)\n",
|
||||
"need imie\n",
|
||||
"state: ['need', 'imie']\n",
|
||||
"inform(imie)\n",
|
||||
"System: Marek Suski\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
Loading…
Reference in New Issue
Block a user